Can't spawn missile in script
Posted: Fri Oct 21, 2011 6:23 am
Greetings all,
I have the latest and greatest version of Oolite (1.75.3). I am working on my own OXP. I am using railgun.oxp as a base (copy 'n paste and edit job).
Instead of spawning a railgun projectile I wish to spawn a missile, so I've edited the code to look like:
The RMB intercept missile is defined in the Missiles and Bombs OXP. The trouble is I get the NOT Spawned message so it doesn't work. So I tried to spawn a regular missile, using this:
and things got really freaky; as far as I could tell it was spawning all kinds of stuff apart from missiles, including interdictor mines and thargons!
This is not my first time at OXP scripting and yes I've read the Javascript manual entry for spawnOne (unfortunately the docco doesn't come with examples and I find the one line "function spawnOne(role : String) : Ship" not terribly helpful). I blatantly swiped the if(!!this.missile)... construct from a website as I want to do a NULL test (yes I can google); the language I work with on a day to day basis has a completely different way of checking for NULLs (var is null, if anyone is wondering).
Anybody any helpful suggestions?
Ta,
Lagrange
I have the latest and greatest version of Oolite (1.75.3). I am working on my own OXP. I am using railgun.oxp as a base (copy 'n paste and edit job).
Instead of spawning a railgun projectile I wish to spawn a missile, so I've edited the code to look like:
Code: Select all
this.missile = player.ship.spawnOne("rmb-intercept-missile");
if(!!this.missile){
player.consoleMessage("Intercept Missile Spawned OK.", 2);
}else{
player.consoleMessage("NOT Spawned !!!!!!!!!!!!!!!!!!!!!!", 2);
}
Code: Select all
this.missile = player.ship.spawnOne("missile");
if(!!this.missile){
player.consoleMessage("Intercept Missile Spawned OK.", 2);
}else{
player.consoleMessage("NOT Spawned !!!!!!!!!!!!!!!!!!!!!!", 2);
}
This is not my first time at OXP scripting and yes I've read the Javascript manual entry for spawnOne (unfortunately the docco doesn't come with examples and I find the one line "function spawnOne(role : String) : Ship" not terribly helpful). I blatantly swiped the if(!!this.missile)... construct from a website as I want to do a NULL test (yes I can google); the language I work with on a day to day basis has a completely different way of checking for NULLs (var is null, if anyone is wondering).
Anybody any helpful suggestions?
Ta,
Lagrange