Page 1 of 1

Ship OXP's should have dummy worldscript.

Posted: Sat Apr 16, 2011 6:14 pm
by Capt. Murphy
Hi,

Just a random thought. It would be quite helpful to scripters who may wish to like_ship to a OXP ship with a custom role to have a method of checking if that ship's OXP is present or not.

If ship OXP makers included as standard a 'dummy' worldscript (headers and a this.startup with a log command perhaps), it would be possible for another worldscript to check to see if the OXP is installed.

For example I'm currently working on a player acting as escort to NPC traders OXP. I could create two custom roles "mother_griff" and "mother_standard". My shipdata.plist could include like_ships to Griff's models and the standard named models. Then my worldscript could check to see if Griffs shipset is installed by referencing it's dummy worldscript and if so use the "mother_griff" role throughout the rest of the script and if not the "mother_standard".

Maybe I'm missing something but I don't think there is an another way to check for the presence of a particular model?

Cheers,

Re: Ship OXP's should have dummy worldscript.

Posted: Sat Apr 16, 2011 6:32 pm
by Commander McLane
You're right, currently there is no way of checking for the presence of an OXP other than to check for its worldscript.

I think this is one of the issues to be addressed by Oolite 2.0. In the meantime a dummy worldscript could help. Of course there's always the problem of the already existing OXPs without a dummy worldscript.

Re: Ship OXP's should have dummy worldscript.

Posted: Mon Apr 18, 2011 9:48 am
by Kaks
Capt. Murphy wrote:
Maybe I'm missing something but I don't think there is an another way to check for the presence of a particular model?
One method you could always use to check for a specific ship:

Code: Select all

this.$roleExitsts = function(roleString) {
    var dummyShips = system.addShips(roleString,1,[100000,100000,100000]); //array containing all ships created by addShips
    var exists = (dummyShips.length == 1);

    if (exists) dummyShips[0].remove(true); //remove test ship as quietly as possible...
    return exists;
}
However, it does require that the ship you're looking for has got a unique role:

Code: Select all

if (this.$roleExists('spiffyOtherShip')) player.consoleMessage('Well, we might have to deal with some Spiffy ships...');
Won't be too helpful if more than one OXP has ships with role spiffyOtherShip! :)

Re: Ship OXP's should have dummy worldscript.

Posted: Mon Apr 18, 2011 3:28 pm
by Eric Walch
Capt. Murphy wrote:
Hi,

Just a random thought. It would be quite helpful to scripters who may wish to like_ship to a OXP ship with a custom role to have a method of checking if that ship's OXP is present or not. ....
For example I'm currently working on a player acting as escort to NPC traders OXP. I could create two custom roles "mother_griff" and "mother_standard". My shipdata.plist could include like_ships to Griff's models and the standard named models. Then my worldscript could check to see if Griffs shipset is installed by referencing it's dummy worldscript and if so use the "mother_griff" role throughout the rest of the script and if not the "mother_standard".
When you do a like_ship to an external oxp you can include the ship_key: is_external_dependency. That way any error reports for non existing ships are suppressed when that other oxp is not installed. In the case of your griff_ships, the like_ship is just not added to your list.
In this case give your own ship a very low probability. When griffs ships are installed, it is likely to choose those. If not it will stick to your own version.