Page 3 of 4

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Wed Mar 23, 2011 11:43 am
by Okti
lave wrote:
I just tested it again (my work can wait lol).

I am still getting the same problem.
I have 1 pod fitted, no breaker and only 1 asteriod within range.

The pod scoops the first splinter then just flys off. I waited for about 10 mins but it never returned.
I am not too good with coding but I had a look and can't seem to see anything wrong.

With the first release of this (when it used to launch 10+ pods) it did actually work for me.

In that case I did edit the 10 to just 1 so that there was just one pod and it worked fine.
I am Playing with this for 6 hours now, with only one miner. I could not reproduce the bug you mentioned. After scooping it always returns to be collected. The version you mentioned was a lot bugier than that because target lost events were handled as cargo_sccoped, which did not match the visual number of splinters sccoped.

I don't think it will make much difference but, What is your operating system?

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Wed Mar 23, 2011 11:54 am
by lave
I'm on Windows Vista.

The first version you made seemed to work fine. The pod/s scooped all spliters then returned.

Now the pod flys off even though there are other splinters floating around.

Oh well, it's not a problem. I will continue to mine the old fashioned way lol.

Thanks.

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Wed Mar 23, 2011 12:01 pm
by Okti
I will PM you a link for the old version.

Thanks.

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Wed Mar 23, 2011 12:19 pm
by Disembodied
I'm no use at the programming side but I can spot a typo ... should be "1 ton of Minerals collected"! :)

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Wed Mar 23, 2011 12:35 pm
by lave
Okti wrote:
I will PM you a link for the old version.

Thanks.

Cheers.

At least I can edit the code to only have 1 pod (which I prefer anyway).

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Fri May 13, 2011 10:22 am
by maik
Added to the WIP section of the [wiki]OXP List[/wiki].

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Thu Jan 12, 2012 11:09 am
by SandJ
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.

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Thu Jan 12, 2012 11:24 am
by Micha
SandJ wrote:
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.
Something which can help here is version control software. These are getting very easy to use and can easily be integrated with the desktop. Check out TortoiseGIT for Windows, for example, no need for a server or anything else.
Also allows you to very easily compare past versions so you can see what you changed - especially useful if you're just trying something out.

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Fri May 18, 2012 6:39 pm
by SandJ
In latest.Log on my case-sensitive Linux box:

Code: Select all

[script.load.notFound]: ***** Could not find a script file named MinerPod.js.
In [size=120]MinerPod v0.1.oxp\Config\shipdata.plist[/size] there is:

Code: Select all

      script = "MinerPod.js"
which I think needs to be:

Code: Select all

      script = "minerPod.js"
Edit: There's more:
Latest.log wrote:
18:36:49.903 [ai.load.failed.unknownAI]: Can't switch AI for <ShipEntity 0x7f6cb4036820>{"MinerPodRockBreaker"} to "MinerPodRockBreakerAI.plist" - could not load file.
18:36:49.904 [script.load.notFound]: ***** Could not find a script file named MinerPodRockBreaker.js.
In [size=120]MinerPod v0.1.oxp\Config\shipdata.plist[/size]

Code: Select all

      ai_type = "MinerPodRockBreakerAI.plist";
...
      script = "MinerPodRockBreaker.js";
to:

Code: Select all

      ai_type = "minerPodRockBreakerAI.plist";
...
      script = "minerPodRockBreaker.js";

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Thu Nov 07, 2013 10:43 pm
by Norby
Due to Okti is missing since April, I uploaded Miner Pod 0.11 which contain SandJ's error fixing suggestions.

Edit: removed until Okti agree it to satisfy the license.

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Sat Nov 09, 2013 7:48 am
by Fatleaf
Norby wrote:
Due to Okti is missing since April, I uploaded Miner Pod 0.11 which contain SandJ's error fixing suggestions.
Ermm...... Have you tried to contact Okti first before changing his work?

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Sat Nov 09, 2013 10:02 am
by JazHaz
Fatleaf wrote:
Norby wrote:
Due to Okti is missing since April, I uploaded Miner Pod 0.11 which contain SandJ's error fixing suggestions.
Ermm...... Have you tried to contact Okti first before changing his work?
Par for the course with Norby. He keeps stepping on people's toes.

Norby, you are allowed to alter anyone's work FOR YOUR OWN USE. However YOU ARE NOT ALLOWED TO RELEASE IT WITHOUT PERMISSION.

Sorry everyone for caps, but Norby doesn't seem to get it.

This is the licence for the Miner Pod OXP. Norby, you have broken the terms in the licence.
License:

This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with the following clauses:

* Whilst you are free (and encouraged) to re-use any of the scripting, models or texturing in this OXP, the usage must be distinct from that within this OXP. Unique identifiers such as (but not limited to) unique shipdata.plist entity keys, mission variables, script names (this.name), equipment identity strings (EQ_), description list arrays and entity roles must not be re-used without prior agreement. Basically if it's unique or would identify or overwrite anything in the original OXP, then you may not re-use it (for obvious compatibility reasons).
* rebundling of this OXP within another distribution is permitted as long as it is unchanged. The following derivates however are permitted and except from the above:
* the conversion of files between XML and openStep.
* the merging of files with other files of the same type from other OXPs.
* The license information (either as this file or merged into a larger one) must be included in the OXP.
* Even though it is not compulsory, if you are re-using any sizable or recognisable piece of this OXP, please let me know :)

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Sat Nov 09, 2013 12:51 pm
by Norby
I really missed it, sorry. Licensing seems to be a minefield to me. Download removed until Okti send a reply although there is a big chance to my PM will be in my outbox forever.

Thank you JazHaz and Fatleaf for the proofreading!

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Sat Nov 09, 2013 12:58 pm
by Smivs
Norby wrote:
there is a big chance to my PM will be in my outbox forever.
Hopefully not. Okti is very busy with RL(TM) at the moment, but I did speak to him in the chatroom a while ago, so he is still with us in spirit, if not in body right now.

Re: [WIP]Miner Pod OXP (v0.1 Released)

Posted: Sat Nov 09, 2013 4:41 pm
by Cody
Norby wrote:
... there is a big chance to my PM will be in my outbox forever.
I'll email Okti tonight and nudge him, Norby... but he doesn't always respond to emails.