Ship OXP's should have dummy worldscript.

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Post Reply
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Ship OXP's should have dummy worldscript.

Post 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,
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Ship OXP's should have dummy worldscript.

Post 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.
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

Re: Ship OXP's should have dummy worldscript.

Post 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! :)
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Ship OXP's should have dummy worldscript.

Post 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.
Post Reply