Nexus Modding > Scripting

Scripting Issues

<< < (10/25) > >>

The Old Dragon:
Try this as your selection instead...


--- Code: ---SelectDevices(1, m.*ship*, s.this:Devtype=#supp_BsGen | s.this:Devtype=#supp_res);
--- End code ---

Your original condition is asking for an item that is both a supp_BsGen and a supp_res. Clearly an imposibility.
This new line asks for an item that is either of those devices.

Mularac:
you're right, that was stupid from my end. But that way wouldn't work either, as the rule will settle with the first one of those two that is true, so the output would only be one device, not the both of them.

Arparso:
How so? SelectDevices selects all devices matching its criteria, not just a single one, so Dragon's line will make selection 1 include all devices of types #supp_BsGen and #supp_res on that particular ship.

Mularac:
well... with the debug commands I tracked the variables down to this:

This is the code:

--- Code: ---SelectDevices(1, m.ac,  InSet(s.this,66)| InSet(s.this,42));
Execlist(1,
debug("1",s.this);
dev:=s.this;
Debug("2",dev);
);

Debug("----------------The devices are:", dev);

--- End code ---

and this is what the console gave me:


--- Code: ---        1  shield/HybridShieldMk3
        2  shield/HybridShieldMk3
        1  device/supp_res
        2  device/supp_res
        ----------------The devices are:  device/supp_res

--- End code ---

funny, eh? The selectdevices did indeed select both ones, I was wrong about that one too, but when the "dev" variable left the execlist command it only stayed with the first one, so when I tried it only one of the devices got enabled, hence my previous post. Most peculiar indeed.

The Old Dragon:
The reason that Nexus is only giving you the one debug line  instead of three is because the last 'debug' command is outside of the 'execlist' command.

 If you were to place it within the  parenthesis  (you know, the '()' that surround this little explanation ) then the debug line would fire for each device and as in a circumstance like this, Nexus collects up the various items that fulfill the criteria and puts them in a list. Then it'll take the first item and run through any commands in the execlist that are applicable and when it's done, Nexus puts down item one and picks up item two, executes the commands,puts it down,item three, etc.  You get the idea.

Then it'll proceed with the rest of the command. But as the 'dev' variable can only store one value, only the last run through of the previous 'execlist' command will be recorded.

So this is how I believe it should have read...


--- Code: ---SelectDevices(1, m.ac,  InSet(s.this,66)| InSet(s.this,42));
Execlist(1,
debug("1",s.this);
dev:=s.this;
Debug("2",dev);
        Debug("----------------The devices are:", dev);
);
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version