Mission variables

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

Moderators: winston, another_commander

Post Reply
User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 847
Joined: Tue Sep 07, 2010 2:23 pm

Mission variables

Post by Mauiby de Fug »

I'm dabbling about in writing my own oxps now, or at least, trying to familiarize myself with the way that Oolite works.

From what I can tell, the only way to get a variable that lasts longer after Oolite shuts down is to save it as a mission variable in the save game.

I may be being rather dense, but I can't work out how to create one. I've trawled through the wiki pages, and had a nosey in the other oxps on my computer, but my poor brain's beginning to melt. I've probably seen it half a dozen times by now, but I haven't yet recognised it or been able to reproduce it.

Can anyone tell me how to create one? Or give me an example where upon docking at, say, "My new Station", it saves a variable saying "HAS DOCKED"?

I eventually managed to create a station today. There's something very satisfying about telling it to spawn in the console and seeing it appear in nearby space, and having something come up in the Advanced Space Compass! Even if it looks identical to a lowly Rock Hermit! And especially after one spent over an hour trying to work out why one's supposedly perfectly valid code refused to parse, and the problem is finally solved by copying and pasting it a few lines at a time until one finds the lack of a / in an </key>!

(Mastering Wings to get something that looks useable is proving tricky at the moment, so I'm persevering and dabbling in the scripting side of things while I get to grips with it!)
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

In javascript, from the console:

Code: Select all

missionVariables.testing='yep,testing';
Save your game, close Oolite.
Restart Oolite, load your game, type

Code: Select all

missionVariables.testing
the console should display

yep,testing


Did you read the following page?

http://wiki.alioth.net/index.php/Oolite ... ce:_Global
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 847
Joined: Tue Sep 07, 2010 2:23 pm

Post by Mauiby de Fug »

Aha! It worked! Now to get the hang of event handling!

And no, I hadn't found that page, alas. If only I'd found that one instead of the other or so that I've got open in my browser...

Thanks for the info!
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

If you're embarking on the road to OXP scripting wisdom (or madness), it's worth consuming, digesting and cogitating all of the Javascript reference pages on the wiki.

Also learning golden rule 1b - for OXPs it's a good habit to get into to make all OXP-specific things such as mission variables, unique roles, ship identifiers and so forth unique by sticking either your name or the name of your OXP in front of them (see most published OXPs for examples). It just saves future clash risks from using generic names (having two OXPs sharing the same MV for example, and one changing things and screwing up the other).
User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 847
Joined: Tue Sep 07, 2010 2:23 pm

Post by Mauiby de Fug »

Thargoid wrote:
If you're embarking on the road to OXP scripting wisdom (or madness), it's worth consuming, digesting and cogitating all of the Javascript reference pages on the wiki.
I had a look through a whole bunch of them; that one must have slipped me by...
Thargoid wrote:
Also learning golden rule 1b - for OXPs it's a good habit to get into to make all OXP-specific things such as mission variables, unique roles, ship identifiers and so forth unique by sticking either your name or the name of your OXP in front of them (see most published OXPs for examples). It just saves future clash risks from using generic names (having two OXPs sharing the same MV for example, and one changing things and screwing up the other).
I was doing that already, having noticed the numerous warnings about it posted all over the forums, and seeing the way things are labelled in both the oxps and the savegames! 'Tis a most sensible convention!
Post Reply