View Full Version : ItemActive state

01-20-2009, 09:06 PM
In versons of LW prior to 9.6 version ItemActive(0); or ItemActive(1); were working as a toggle, no matter which one you use it would toggle item activity flag.
Now in LW96 ItemActive(); works as it supposed... ItemActive(0); deactivates selected item and ItemActive(1); activates... no toggle anymore.
And there is a problem: How to get ItemActive state of current item?
Looks like LS Reference has no any data members on this subject listed.

Maybe there's not documented way? Does anyone know?
Or maybe an advice how to write ItemActivite toggle code? :)

"Obj.active" doesn't work :)

01-23-2009, 12:59 PM
Was facing the same trouble, and solved it like this:
- Save a copy of the scene file and scan it.
- When an object is set to inactive, one of the last entries for this object will be "ItemActive 0". When it's active, this entry is missing.
- Remember the start state in an array, and everytime you change the state, you also change your own variable.

And yes, the scanning is a hassle, and if you figure out a better way I would be intrested as well...


02-26-2009, 10:28 AM
I got a solution for the ItemActive() function. Always prefer the CS equivalent to the LS one. NT only implements the LScript functions after they have implemented the commands in the SDK/internally. And history have shown there is seldome a 1:1 conversion. So go directly to the source. Use CommandInput()!

All these work as expected!

CommandInput("ItemActive 1");
CommandInput("ItemActive 0");

Walfridson pointed out this thread to me when I had another related issue, executing CommandInput("ItemActive (Null)") in my MultiService script which is what the process/evaluate function in a master script gives you when executing ItemActive command. This worked fine in 8.5 but not in 9.6 because some function prototypes were changed. 9.6 didn't like the "(Null)" part. But this made me realize what the recent changes meant and also reaffirmed my belief that it is smarter to invoke the CS commands rather than LS functions. Code isn't as readable but atleast you don't risk any LScript related issues.