Page 2 of 4

Re: Station Defense Minigame

Posted: Thu May 31, 2012 12:10 pm
by m4r35n357
Commander Xvyto wrote:
No sense reinventing the (dark) wheel
I dunno. For me (at least in programming) I've learned better not by copying stuff but writing it myself, because it forces me to understand.
If you are "good enough" at studying APIs and putting all the disparate pieces together from scratch then that's fine, but IMO there is quite a large barrier to entry that way. OTOH by starting with an existing OXP you can get going right away with working code; to me that is priceless.

Re: Station Defense Minigame

Posted: Thu May 31, 2012 1:56 pm
by Commander Xvyto

Code: Select all

this.shipDockedWithStation = function(station)
    {
    mission.runScreen({titleKey:"stationDefenseScreen1", messageKey:"stationDefenseScreen1"});
}
So I tried using this, but when I dock, nothing happens. Is it a problem with my syntax or .plists? I have gotten the game to send me console messages, but nothing beyond that.

Edit: In the worldscripts.plist the only script I have listed is this one. Does the script need to be in the Config folder?

Re: Station Defense Minigame

Posted: Thu May 31, 2012 2:03 pm
by cim
Commander Xvyto wrote:

Code: Select all

this.shipDockedWithStation = function(station)
    {
    mission.runScreen({titleKey:"stationDefenseScreen1", messageKey:"stationDefenseScreen1"});
}
So I tried using this, but when I dock, nothing happens. Is it a problem with my syntax or .plists? I have gotten the game to send me console messages, but nothing beyond that.

Edit: In the worldscripts.plist the only script I have listed is this one. Does the script need to be in the Config folder?
Your script should be in the Scripts folder and listed in worldscripts.plist (it sounds like this is what you're doing already, so that's okay)

Your missiontext.plist file must contain an entry called "stationDefenseScreen1" (obviously you'll want separate title and message keys once you've got it working, but this should work fine for testing)

You should probably use this.missionScreenOpportunity rather than this.shipDockedWithStation - I suspect that some other changes after the docking event are affecting the display of the mission screen. It also stops interference with other mission screens from other OXPs.

Re: Station Defense Minigame

Posted: Thu May 31, 2012 2:06 pm
by Commander Xvyto
When is missionScreenOpportunity called?

Edit: Looked it up on the wiki.

Re: Station Defense Minigame

Posted: Thu May 31, 2012 2:13 pm
by cim
Commander Xvyto wrote:
When is missionScreenOpportunity called?
On three occasions:
- After the arrival reports (e.g. people in escape pods you have rescued) are over, but before the F5 status screen comes up
- On game startup, just before the F5 status screen comes up
- After a mission screen ends without itself calling mission.runScreen

See the docs for more: missionScreenOpportunity

Re: Station Defense Minigame

Posted: Thu May 31, 2012 2:16 pm
by Commander Xvyto

Code: Select all

this.missionScreenOpportunity = function()
    }
     mission.runScreen({messageKey:"stationDefenseScreen1"});
}
I changed it to this. However, it still doesn't call the mission screen. For mission.runScreen, am I missing some parameters?

Re: Station Defense Minigame

Posted: Thu May 31, 2012 2:27 pm
by cim
Commander Xvyto wrote:

Code: Select all

this.missionScreenOpportunity = function()
    [u][b]}[/b][/u]
     mission.runScreen({messageKey:"stationDefenseScreen1"});
}
I changed it to this. However, it still doesn't call the mission screen. For mission.runScreen, am I missing some parameters?
All worldscripts need a name. You should have

Code: Select all

this.name = "...";
as the very first line in your script file. (It doesn't, strictly, have to be the first one, but it's easier to read that way). Replace "..." with something else, bearing in mind that whatever you choose has to be unique - "StationDefenseMinigame-main" or something like that.

Assuming the brace highlighted above is really the other way round in your code, and you've named the worldscript, it's probably time to check your Latest.log

If you've made some coding error, it'll show up there - either near the top when the worldscripts are being loaded, or near the bottom when it tries to run the mission screen.

(Also, for the really obvious stuff which everyone forgets once or twice: this script is in a Scripts folder which is itself inside an OXP folder inside your AddOns folder; you have made sure Oolite is clearing its OXP cache by holding shift at startup, changing the config parameter, or changing the timestamp on your OXP folder)

Re: Station Defense Minigame

Posted: Thu May 31, 2012 2:42 pm
by Commander Xvyto
Thanks a lot! I changed those two things, and now the screen shows up.

Re: Station Defense Minigame

Posted: Thu May 31, 2012 2:48 pm
by Cody
Commander Xvyto wrote:
Thanks a lot! I changed those two things, and now the screen shows up.
<chortles> He's hooked!

Re: Station Defense Minigame

Posted: Thu May 31, 2012 2:53 pm
by Commander Xvyto
He's hooked!
Unfortunately, I think you're right. 8) <waves goodbye to his life that is running away into the distance>

Re: Station Defense Minigame

Posted: Thu May 31, 2012 2:53 pm
by Smivs
Commander Xvyto wrote:
He's hooked!
Unfortunately, I think you're right. 8) <waves goodbye to his life that is running away into the distance>
:D

Re: Station Defense Minigame

Posted: Thu May 31, 2012 3:00 pm
by Commander Xvyto
I've been doing programming since 5th grade, and I've always loved that one moment of discovery when you see how everything works and wonder how you missed it.

Re: Station Defense Minigame

Posted: Thu May 31, 2012 3:06 pm
by Smivs
I have to admit I still experience an almost child-like glee when I get something working! :)

Re: Station Defense Minigame

Posted: Thu May 31, 2012 3:16 pm
by Commander Xvyto
I think that is quite common among programmers/oxpers/anyone who works with code-ers.

Re: Station Defense Minigame

Posted: Thu May 31, 2012 7:32 pm
by CommonSenseOTB
Commander Xvyto wrote:
I think that is quite common among programmers/oxpers/anyone who works with code-ers.
Umm...yep. :)