Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Station Defense Minigame

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

m4r35n357
---- E L I T E ----
---- E L I T E ----
Posts: 296
Joined: Wed Jan 19, 2011 4:00 pm

Re: Station Defense Minigame

Post 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.
User avatar
Commander Xvyto
Competent
Competent
Posts: 47
Joined: Mon May 28, 2012 10:52 pm
Location: Raisso

Re: Station Defense Minigame

Post 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?
Currently in G1.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Station Defense Minigame

Post 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.
User avatar
Commander Xvyto
Competent
Competent
Posts: 47
Joined: Mon May 28, 2012 10:52 pm
Location: Raisso

Re: Station Defense Minigame

Post by Commander Xvyto »

When is missionScreenOpportunity called?

Edit: Looked it up on the wiki.
Last edited by Commander Xvyto on Thu May 31, 2012 2:16 pm, edited 2 times in total.
Currently in G1.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Station Defense Minigame

Post 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
User avatar
Commander Xvyto
Competent
Competent
Posts: 47
Joined: Mon May 28, 2012 10:52 pm
Location: Raisso

Re: Station Defense Minigame

Post 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?
Currently in G1.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Station Defense Minigame

Post 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)
User avatar
Commander Xvyto
Competent
Competent
Posts: 47
Joined: Mon May 28, 2012 10:52 pm
Location: Raisso

Re: Station Defense Minigame

Post by Commander Xvyto »

Thanks a lot! I changed those two things, and now the screen shows up.
Currently in G1.
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16073
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Station Defense Minigame

Post by Cody »

Commander Xvyto wrote:
Thanks a lot! I changed those two things, and now the screen shows up.
<chortles> He's hooked!
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
Commander Xvyto
Competent
Competent
Posts: 47
Joined: Mon May 28, 2012 10:52 pm
Location: Raisso

Re: Station Defense Minigame

Post 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>
Currently in G1.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Station Defense Minigame

Post 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
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Commander Xvyto
Competent
Competent
Posts: 47
Joined: Mon May 28, 2012 10:52 pm
Location: Raisso

Re: Station Defense Minigame

Post 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.
Currently in G1.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Station Defense Minigame

Post by Smivs »

I have to admit I still experience an almost child-like glee when I get something working! :)
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Commander Xvyto
Competent
Competent
Posts: 47
Joined: Mon May 28, 2012 10:52 pm
Location: Raisso

Re: Station Defense Minigame

Post by Commander Xvyto »

I think that is quite common among programmers/oxpers/anyone who works with code-ers.
Currently in G1.
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: Station Defense Minigame

Post by CommonSenseOTB »

Commander Xvyto wrote:
I think that is quite common among programmers/oxpers/anyone who works with code-ers.
Umm...yep. :)
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
Post Reply