What is wrong in these commands?
selectex(s.race=#race_player,disappear(s.this));
selectex(s.race=#race_player,SetLongRangeDir(s.this,JumpVector,0,0);longrangearrive(s.this););
It says : s.this is not a ship, but i selected all ships that the player controls
Actually you didn't. Just replace these commands with the following and you'll see, what you really selected:
Select(1, s.race = #race_player);
Dump(1);
This should give you a list of all player controlled ships
and all devices in the scene (even the ones on AI ships).
Why this happens:Nexus employs a rather liberal use of variables. You can check objects for variables, that they don't actually have set. These variables will return a value of 0, if they haven't been set to anything else. You can try
Select(1, S.MyOwnVar = 0); to select about everything in the scene, because every object reports a value of 0 for your newly invented variable - so the Select condition is always true.
The same happens here: devices don't have a race variable, so you'd think they shouldn't be returned by the above Select or SelectEx statements. However, #race_player usually represents the numeric value of 0 (check "races.ini" for that... #race_player is most likely to be "RACE 0"). Knowing that, the condition "
s.race = #race_player" actually means "
s.race = 0" and that returns true for all ships belonging to that race
and all other objects not having their own race-variable (like devices).
How to fix it:Long story short, simply include "
& s.ship" in your SelectEx condition and everything else not being a ship won't be catched by that statement:
selectex(s.race=#race_player & s.ship,disappear(s.this));
selectex(s.race=#race_player & s.ship,SetLongRangeDir(s.this,JumpVector,0,0);longrangearrive(s.this););