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,
Ship OXP's should have dummy worldscript.
Moderators: winston, another_commander
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Ship OXP's should have dummy worldscript.
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
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
- Commander McLane
- ---- 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.
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.
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.
One method you could always use to check for a specific ship: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?
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;
}
Code: Select all
if (this.$roleExists('spiffyOtherShip')) player.consoleMessage('Well, we might have to deal with some Spiffy ships...');
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Ship OXP's should have dummy worldscript.
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.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".
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.
UPS-Courier & DeepSpacePirates & others at the box and some older versions