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.Commander Xvyto wrote: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.No sense reinventing the (dark) wheel
Station Defense Minigame
Moderators: winston, another_commander
Re: Station Defense Minigame
OXPs: Furball 1.8, Factions 1.12
- Commander Xvyto
- Competent
- Posts: 47
- Joined: Mon May 28, 2012 10:52 pm
- Location: Raisso
Re: Station Defense Minigame
Code: Select all
this.shipDockedWithStation = function(station)
{
mission.runScreen({titleKey:"stationDefenseScreen1", messageKey:"stationDefenseScreen1"});
}
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.
Re: Station Defense Minigame
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)Commander Xvyto wrote: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.Code: Select all
this.shipDockedWithStation = function(station) { mission.runScreen({titleKey:"stationDefenseScreen1", messageKey:"stationDefenseScreen1"}); }
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 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.
- Commander Xvyto
- Competent
- Posts: 47
- Joined: Mon May 28, 2012 10:52 pm
- Location: Raisso
Re: Station Defense Minigame
When is missionScreenOpportunity called?
Edit: Looked it up on the wiki.
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.
Re: Station Defense Minigame
On three occasions:Commander Xvyto wrote:When is missionScreenOpportunity called?
- 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
- Commander Xvyto
- Competent
- Posts: 47
- Joined: Mon May 28, 2012 10:52 pm
- Location: Raisso
Re: Station Defense Minigame
Code: Select all
this.missionScreenOpportunity = function()
}
mission.runScreen({messageKey:"stationDefenseScreen1"});
}
Currently in G1.
Re: Station Defense Minigame
All worldscripts need a name. You should haveCommander Xvyto wrote:I changed it to this. However, it still doesn't call the mission screen. For mission.runScreen, am I missing some parameters?Code: Select all
this.missionScreenOpportunity = function() [u][b]}[/b][/u] mission.runScreen({messageKey:"stationDefenseScreen1"}); }
Code: Select all
this.name = "...";
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)
- Commander Xvyto
- Competent
- Posts: 47
- Joined: Mon May 28, 2012 10:52 pm
- Location: Raisso
Re: Station Defense Minigame
Thanks a lot! I changed those two things, and now the screen shows up.
Currently in G1.
- Cody
- Sharp Shooter Spam Assassin
- Posts: 16081
- Joined: Sat Jul 04, 2009 9:31 pm
- Location: The Lizard's Claw
- Contact:
Re: Station Defense Minigame
<chortles> He's hooked!Commander Xvyto wrote:Thanks a lot! I changed those two things, and now the screen shows up.
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!
And any survivors, their debts I will certainly pay. There's always a way!
- Commander Xvyto
- Competent
- Posts: 47
- Joined: Mon May 28, 2012 10:52 pm
- Location: Raisso
Re: Station Defense Minigame
Unfortunately, I think you're right. <waves goodbye to his life that is running away into the distance>He's hooked!
Currently in G1.
- Smivs
- Retired Assassin
- Posts: 8408
- Joined: Tue Feb 09, 2010 11:31 am
- Location: Lost in space
- Contact:
Re: Station Defense Minigame
Commander Xvyto wrote:Unfortunately, I think you're right. <waves goodbye to his life that is running away into the distance>He's hooked!
Commander Smivs, the friendliest Gourd this side of Riedquat.
- Commander Xvyto
- Competent
- Posts: 47
- Joined: Mon May 28, 2012 10:52 pm
- Location: Raisso
Re: Station Defense Minigame
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.
- Smivs
- Retired Assassin
- Posts: 8408
- Joined: Tue Feb 09, 2010 11:31 am
- Location: Lost in space
- Contact:
Re: Station Defense Minigame
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.
- Commander Xvyto
- Competent
- Posts: 47
- Joined: Mon May 28, 2012 10:52 pm
- Location: Raisso
Re: Station Defense Minigame
I think that is quite common among programmers/oxpers/anyone who works with code-ers.
Currently in G1.
- CommonSenseOTB
- ---- E L I T E ----
- Posts: 1397
- Joined: Wed May 04, 2011 10:42 am
- Location: Saskatchewan, Canada
Re: Station Defense Minigame
Umm...yep.Commander Xvyto wrote:I think that is quite common among programmers/oxpers/anyone who works with code-ers.
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
CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs