Hi all
I'm asking for a bit of help. I need to be able to determine which ships are near the player's escape capsule, but:
(1) seemingly I can't use player.ship.position for this, because, by the time the this.escapePodSequenceOverhandler fires, or even the handler this.shipLaunchedEscapePod, that variable is invalid;
(2) this.shipLaunchedEscapePod does give me the escapepod entity to use, but its reported position seems fixed at (!) 0,0,0.
Help! Sorry if I am missing something (it is rather late . .).
Getting ship or escapepod co-ordinates when player ejects
Moderators: winston, another_commander
Re: Getting ship or escapepod co-ordinates when player eject
You can doUK_Eliter wrote:(1) seemingly I can't use player.ship.position for this, because, by the time the this.escapePodSequenceOverhandler fires, or even the handler this.shipLaunchedEscapePod, that variable is invalid;
(2) this.shipLaunchedEscapePod does give me the escapepod entity to use, but its reported position seems fixed at (!) 0,0,0.
Code: Select all
system.filteredEntities(this, function () { return true; }, player.ship, 25600);
-
- ---- E L I T E ----
- Posts: 1248
- Joined: Sat Sep 12, 2009 11:58 pm
- Location: Essex (mainly industrial and occasionally anarchic)
Re: Getting ship or escapepod co-ordinates when player eject
Thanks a lot for that cim. It does indeed work. The problem must have been elsewhere in my script ('cos I was trying that before). The problem might have been multi-line filter functions, along the lines of:
Is that sort of use of split lines OK?
Code: Select all
function $otherShipsToRemove(e)
{
return
(
!e.isPlayer && !e.isPolice && !e.scanClass == "CLASS_MILITARY"
&& !e.hasRole("IST_mil") && !e.hasRole("spectre")
&& !e.hasRole("IST_alloy") && !e.hasRole("IST_alien_cargopod") && !e.hasRole("asteroid")
&& !e.hasRole("hiredGuns_escort") && !e.hasRole("ecl_escape_pod_beacon") && !e.hasRole("escape-capsule")
);
}
- 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: Getting ship or escapepod co-ordinates when player eject
Yes, it should be. As long as all the brackets etc. are correct, of course.
Speaking of which, I'm not sure whether the ()-parenthesis is correct in this specific example. I have usually not used it for a
Speaking of which, I'm not sure whether the ()-parenthesis is correct in this specific example. I have usually not used it for a
return
condition. Thus I'd write
Code: Select all
function $otherShipsToRemove(e)
{
return !e.isPlayer && !e.isPolice && !e.scanClass == "CLASS_MILITARY" && !e.hasRole("IST_mil") && !e.hasRole("spectre") && !e.hasRole("IST_alloy") && !e.hasRole("IST_alien_cargopod") && !e.hasRole("asteroid") && !e.hasRole("hiredGuns_escort") && !e.hasRole("ecl_escape_pod_beacon") && !e.hasRole("escape-capsule")
}
-
- ---- E L I T E ----
- Posts: 1248
- Joined: Sat Sep 12, 2009 11:58 pm
- Location: Essex (mainly industrial and occasionally anarchic)
Re: Getting ship or escapepod co-ordinates when player eject
Thanks! Anyone else, though, have a view on the matter of the bracket type?Commander McLane wrote:Yes, it should be. As long as all the brackets etc. are correct, of course.
Speaking of which, I'm not sure whether the ()-parenthesis is correct in this specific example. I have usually not used it for areturn
condition. Thus I'd writeCode: Select all
function $otherShipsToRemove(e) { return !e.isPlayer && !e.isPolice && !e.scanClass == "CLASS_MILITARY" && !e.hasRole("IST_mil") && !e.hasRole("spectre") && !e.hasRole("IST_alloy") && !e.hasRole("IST_alien_cargopod") && !e.hasRole("asteroid") && !e.hasRole("hiredGuns_escort") && !e.hasRole("ecl_escape_pod_beacon") && !e.hasRole("escape-capsule") }
(
and )
- but just removed them . . I suppose one needs them when the boolean could evaluate different ways depending on how one interpreted it, i.e. one needs the brackets when one would need them in algebra, and not otherwise. EDIT again: so you'd need brackets for the following (which does indeed contain brackets - and it's from code of mine):
Code: Select all
function $isNavalCarrier(e) { return e.isShip && ( e.hasRole("behemoth") || e.hasRole("leviathan") ) }
Last edited by UK_Eliter on Mon Oct 14, 2013 5:20 pm, edited 1 time in total.
- 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: Getting ship or escapepod co-ordinates when player eject
Yep. But this also means that they can't hurt if put around the whole condition. So that was probably a false alarm.UK_Eliter wrote:I suppose one needs them when the boolean could evaluate different ways depending on how one interpreted it, i.e. one needs the brackets when one would need them in algebra, and not otherwise. EDIT again: so you'd need brackets for the following (which does indeed contain brackets - and it's from code of mine):Code: Select all
function $isNavalCarrier(e) { return e.isShip && ( e.hasRole("behemoth") || e.hasRole("leviathan") ) }
- Tricky
- ---- E L I T E ----
- Posts: 821
- Joined: Sun May 13, 2012 11:12 pm
- Location: Bradford, UK. (Anarchic)
Re: Getting ship or escapepod co-ordinates when player eject
Javascript automatically inserts a semi-colon on a new line, Whitespace and semicolons, so it probably is best to have brackets for a return statement.