New Ship's Role

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

Moderators: winston, another_commander

User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1385
Joined: Thu Apr 28, 2011 3:17 pm

Re: New Ship's Role

Post by mandoman »

Gimi wrote:
Mandoman, without the slightest knowledge of Java-script, I am going to forward some advice that Ahruman seems quite adamant about. Please use unique non-generic names for your scripts and plists. This to avoid conflicts with other OXP's. So rather than "missile.js", use "myoxp_missile.js".
OK, I see what you mean. I'll make those changes right away. Thanks for the info.
Eric Walch wrote:
Same is true for ship keys in shipdata.plist. e.g. when I look in the shipdata of the wip version of 'XeptatisSword', I see keys that are just waiting to generate name conflicts: 'array', 'target', 'projection', 'spike' etc. When two oxps use the same name for their ship reference, only one will load in game and the other will get quite different 'ships' than expected. Or none at all because of other roles in that other oxp.
Yeah, I've been warned about that before. I try to make the shipdata.plist as unique as I can, but I sure can't guarantee zero mistakes. I also try to test my oxps to the extreme, just to flush such errors. If my oxps really start screwing up the game, I either dump them (if I can't work out the problems), or put them on a back burner for a while. This one I'm working on is far from being released.
Capt. Murphy wrote:
Nice one Mandoman - the online JS tutorials are good for understanding the syntax of JS and also the use of it's inbuilt functions (things like Math.random etc).

For Oolite you also need to get your head around around the game engine hooks onto your scripts, which is normally via blocks of code in functions defined under an event handler. Your code is run everytime the event happens in Oolite. For example code to check conditions and spawn a custom role ship would often be found in a...

Code: Select all

this.shipWillExitWitchspace = function()
{
     // Your code here
}

....code block which runs every time the player is about to exit witch space.

You can also have your own functions that are not defined by an Oolite event handler, but their code would normally be called from elsewhere within the script or in the case of a ship script potentially from the AI.plist of that ship.
Yeah, that was about it. I just had to begin understanding the code, and how the commands work to get a certain response. That piece of code you gave as an example is close to some of what I used. It can be confusing, for sure. I kind of understand that "math" function, but it will be a while before I try using it. :)
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
Post Reply