View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:02 am



Reply to topic  [ 9 posts ] 
 Open doors in lua? 
Author Message
User avatar

Joined: Fri Jul 17, 2009 5:25 pm
Posts: 26
Location: Poland, ME, USA
Reply with quote
Post Open doors in lua?
Has anyone found a way to force open or close doors using lua? I've resorted to gibbing them for the time being, but it isn't ideal. :roll:


Sat Jul 18, 2009 6:00 pm
Profile ICQ YIM WWW
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Open doors in lua?
Spawn in a invisible actor.


Sat Jul 18, 2009 7:28 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Open doors in lua?
door:GetController():SetState(Controller.PRIMARY_ACTION,true);


Sun Jul 19, 2009 5:11 am
Profile
User avatar

Joined: Fri Jul 17, 2009 5:25 pm
Posts: 26
Location: Poland, ME, USA
Reply with quote
Post Re: Open doors in lua?
I've tried that, to no avail:

Code:
   -- Open the bay doors
   for Door in MovableMan.Actors do      
      if Door.ClassName == "ADoor" then         
         if tostring( Door ) == "Door Rotate Long, ADoor" then
            print( "Opening: " .. tostring( Door ) .. " #" .. tostring( Door.ID ) );
            Door:GetController():SetState( Controller.PRIMARY_ACTION, true );
         end
      end   
   end


An invisible actor is a good idea, albeit a bit hacky. I'd like to avoid it if there is any other way.


Sun Jul 19, 2009 4:31 pm
Profile ICQ YIM WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Open doors in lua?
Quote:
-- Open the bay doors
for door in MovableMan.Actors do
if door.ClassName == "ADoor" then
if door.PresetName == "Door Rotate Long" then
print( "Opening: " .. tostring( door ) .. " #" .. tostring( door.ID ) );
door:GetController():SetState( Controller.PRIMARY_ACTION, true );
end
end
end


Dunno what all this tostring business is but you shouldn't need it.


Sun Jul 19, 2009 4:40 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Open doors in lua?
I didn't know that the primary action on a door was to open.

But yea, tostring is uneeded. It only exists possibly as fast way to check both class and preset.


Sun Jul 19, 2009 8:05 pm
Profile
User avatar

Joined: Fri Jul 17, 2009 5:25 pm
Posts: 26
Location: Poland, ME, USA
Reply with quote
Post Re: Open doors in lua?
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?


Mon Jul 20, 2009 3:54 am
Profile ICQ YIM WWW
User avatar

Joined: Sun Jul 26, 2009 12:06 am
Posts: 23
Reply with quote
Post Re: Open doors in lua?
Quote:
Why can't rockets drop straight?


I think it is their programming that is at fault...
I have to steer mine if I want them accurate.


Mon Jul 27, 2009 7:09 pm
Profile
User avatar

Joined: Fri Jul 17, 2009 5:25 pm
Posts: 26
Location: Poland, ME, USA
Reply with quote
Post Re: Open doors in lua?
Commander Swift wrote:
Quote:
Why can't rockets drop straight?


I think it is their programming that is at fault...
I have to steer mine if I want them accurate.

On that note, I officially gave up on having hangar doors open when a rescue rocket is created. My solution was to make a Guided Rocket Silo which guides the AI controlled rockets into a perfect landing.


Mon Jul 27, 2009 10:41 pm
Profile ICQ YIM WWW
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.035s | 13 Queries | GZIP : Off ]