Okti, some suggestions which may or may not be helpful.
1. Some files say
this.author = "Okti"
and some say
this.author = "Oktay"
2. As Disembodied said, in minerPodAutoMiner.js and minerPodAutoMinerHelpers.js, "1 Tone" should be either "1 tonne" or "1 ton".
3. On the Wiki page
Scripting Oolite with JavaScript it says:
Ensure you change at least the Name value. Every script must have a unique name. If multiple scripts with the same name are encountered, Oolite will arbitrary select one and discard the others.
but
Code: Select all
minerPodAutoMiner.js says this.name = "minerPodAutoMiner";
minerPodAutoMinerHelpers.js says this.name = "minerPodAutoMiner"; <--- wrong
minerPodForCollection.js says this.name = "minerPodForCollection";
minerPodRockBreaker.js says this.name = "minerPodAutoMiner"; <--- wrong
4. The script minerPodAutoMiner.js is more recent than and contains more functionality than minerPodAutoMinerHelpers.js e.g. this.locatePlayer() and thisShipWasScooped () - is that intentional?
5. In minerPodAutoMiner.js all the code in this.shipSpawned() is commented out - is this intentional? Ditto for minerPodRockBreaker.js
6. Does it matter that minerPodForCollection.js does not refer to gem stones or alloys whilst the other js files do?
7. Should this code:
Code: Select all
this.quant = Math.round(Math.random() * 15 + 0.5);
missionVariables.MinerPod_gold +=quant;
this.comod = this.quant + " kgrms of Gold Collected";
be saying "+=
this.quant" on the 2nd line? (I expect it makes no difference, it just looks odd.)
8. Every time Math.random() is called, it returns a different number. Remember that when constructing if / else statements. The following does work but will not do quite what you expect.
Code: Select all
if (Math.random() < .3)
{
this.quant = Math.round(Math.random() * 15 + 0.5);
missionVariables.MinerPod_gold +=quant;
this.comod = this.quant + " kgrms of Gold Collected";
}
else if (Math.random() <.5)
{
this.quant = Math.round(Math.random() * 15 + 0.5);
missionVariables.MinerPod_platinum +=quant;
this.comod = this.quant + " kgrms of Platinum Collected";
}
else
{
this.quant = Math.round(Math.random() * 15 + 0.5);
missionVariables.MinerPod_gems +=quant;
this.comod = this.quant + " grms of Gem Stones Collected";
}
Instead you are better off assigning Math.random() to a variable, then referring to the variable since it will not change with every if / else.
9. Random number generation is an inefficient algorithm; the less it is used, the better for performance. That is another reason to assign Math.random() to a variable before doing something. Instead you could do something like this (this is pseudocode, just convert it to JavaScript):
Code: Select all
this.CargoType = Math.random()
if (this.CargoType < 0.21)
cargo += 1 tonne Minerals
elseif (this.CargoType < 0.455)
cargo += 1 tonne Radioactives
elseif (this.CargoType < 0.7)
cargo += 1 tonne Alloys
else // will be one of the expensive items, need to know how much
this.CargoQuantity = Math.ceil(Math.random() * 15 ) // Math.ceil always rounds UP so no "+.5" is needed
if (this.CargoType < 0.79)
cargo += this.CargoQuantity Gold
elseif (this.CargoType < .895)
cargo += this.CargoQuantity Platinum
else
cargo += this.CargoQuantity Gem Stones
Probably better still would be to use switch() / case
10. As Gimi said,
please always change the version number when you upload it. The experience mentioned above of you getting different behaviour from someone else combined with not changing version numbers is a classic problem in software change control. Uploading code that has been commented out is another. It becomes possible you are not uploading what you think you are. No offence is meant, it's 25 years of software development experience talking. It is also a good idea to have a comment in every source file saying what date (even time) you last edited it, and why, for your own benefit. It is tedious, but saves you time in the long run, especially if you get interrupted while working on a change.