I add tostring by habit. Many implementations of lua have errors concatenating and comparing against non-string values. Actually, without it, I get this error from the UserData:
Code:
ERROR: No such operator defined
And thank you for PresetName, that saves me some pain.
Has anyone gotten a door to open or close in lua using PRIMARY_ACTION? I still can't get it to work. The rocket always triggers them too close and they hit it causing it to flip. Gibbing the doors causes them to fall off their hinges and crush my actors in the bunker on both sides.
My updated, non-working code.
Code:
for Door in MovableMan.Actors do
if ( Door.ClassName == "ADoor" )
and ( Door.PresetName == "Door Rotate Long" ) then
print( "Opening: " .. tostring( Door ) .. " #" .. Door.ID );
Door:GetController():SetState( Controller.PRIMARY_ACTION, true );
end
end
In my console, as expected, I see the following, but the doors stay closed.
Code:
PRINT: Opening: Door Rotate Long, ADoor #5
PRINT: Opening: Door Rotate Long, ADoor #7
I've given up for now, using the Rocket Silo from Bunker Modules instead of Hangar A from Bunker Systems. But the effect is terrific when simulated, and then I won't have to cheat and make my rocket locked to a certain point on the X-axis so it makes it in the hole. Why can't rockets drop straight?