Nexus Modding > Scripting
create a wreckyard
The Old Dragon:
Glad to help. :thumbup:
Arparso:
Another simple way to do that:
--- Code: ---SelectEx(S.device & InSelection(MyShips, S.owner), S.this:damage := rnd(0,100));
--- End code ---
If you just want to select stuff to execute commands on these items once and then forget about them, better use "SelectEx()" instead of "Select()" and "ExecList()". SelectEx combines both commands and doesn't store anything in a permanent list.
Hades:
I tried to use the selectex command several times but I fall on a problem :
What is wrong in these commands ?
--- Code: ---selectex(s.race=#race_player,disappear(s.this));
selectex(s.race=#race_player,SetLongRangeDir(s.this,JumpVector,0,0);longrangearrive(s.this););
--- End code ---
It says : s.this is not a ship, but i selected all ships that the player controls :/
other question about something else : can we send a boat to an ally ship ?
And the universe variable U.sthg, that says that we can use these variables everywhere in the universe folder ?
Arparso:
--- Quote from: Hades ---What is wrong in these commands?
--- Code: ---selectex(s.race=#race_player,disappear(s.this));
selectex(s.race=#race_player,SetLongRangeDir(s.this,JumpVector,0,0);longrangearrive(s.this););
--- End code ---
It says : s.this is not a ship, but i selected all ships that the player controls
--- End quote ---
Actually you didn't. Just replace these commands with the following and you'll see, what you really selected:
--- Code: ---Select(1, s.race = #race_player);
Dump(1);
--- End code ---
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:
--- Code: ---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););
--- End code ---
Hades:
ok thanks ! :) But when I do this, the game editor crashes lol, think I will use the classical selectships/execlist
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version