Data Realms Fan Forums http://45.55.195.193/ |
|
Opening Craft Doors with Lua http://45.55.195.193/viewtopic.php?f=73&t=17291 |
Page 1 of 1 |
Author: | CaveCricket48 [ Fri Dec 04, 2009 11:59 pm ] |
Post subject: | Opening Craft Doors with Lua |
How do you open a craft's doors with Lua? Setting the craft's controller to WEAPON_FIRE doesn't work. |
Author: | Grif [ Sat Dec 05, 2009 5:59 am ] |
Post subject: | Re: Opening Craft Doors with Lua |
Set state to PRIMARY_ACTION that should work. |
Author: | CaveCricket48 [ Sun Dec 06, 2009 1:57 am ] |
Post subject: | Re: Opening Craft Doors with Lua |
Doesn't seem to work. My script is attached to the craft and is... Code: function Create(self) self.parent = nil; self.parentgun = nil; self.dooropen = false; self.actionmode = 0; -- 0 is nothing, 1 is sucking, 2 is shooting local curdist = 30 for i = 1,MovableMan:GetMOIDCount()-1 do gun = MovableMan:GetMOFromID(i); if gun.PresetName == "Vacuum Gun" and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < curdist then actor = MovableMan:GetMOFromID(gun.RootID); if MovableMan:IsActor(actor) then self.parent = ToActor(actor); self.parentgun = ToHDFirearm(gun); self.actionmode = 1; self.Team = self.parent.Team; print(self.parent.PresetName); end end end end function Update(self) if MovableMan:IsActor(self.parent) then self.Pos = self.parentgun.MuzzlePos; self.Vel = self.parentgun.Vel; self.RotAngle = self.parentgun.RotAngle; self.AIMode = Actor.AIMODE_STAY; if self.actionmode == 1 then if self.parent:GetController():IsState(Controller.WEAPON_FIRE) then if self.dooropen == false then self:GetController():SetState(Controller.PRIMARY_ACTION,true); self.dooropen = true; print("door open"); end else if self.dooropen == true then self:GetController():SetState(Controller.PRIMARY_ACTION,true); self:GetController():SetState(Controller.PRIMARY_ACTION,true); self.actionmode = 2; end end end if self.actionmode == 2 then local itemcheck = self:Inventory(); if itemcheck == nil then self.ToDelete = true; self.LifeTime = 0; end end end end |
Author: | Mind [ Sun Dec 06, 2009 2:12 am ] |
Post subject: | Re: Opening Craft Doors with Lua |
Maybe it's the face that you have it twice in a row but idk for sure :3 Code: self:GetController():SetState(Controller.PRIMARY_ACTION,true); self:GetController():SetState(Controller.PRIMARY_ACTION,true); |
Author: | CaveCricket48 [ Sun Dec 06, 2009 2:37 am ] |
Post subject: | Re: Opening Craft Doors with Lua |
That's the part where the doors are open, and the Lua makes it close then open it again to eject the inventory. |
Author: | Grif [ Sun Dec 06, 2009 8:03 am ] |
Post subject: | Re: Opening Craft Doors with Lua |
Setting it twice within one sim update probably just makes it never flipflop. |
Author: | mail2345 [ Sun Dec 06, 2009 7:37 pm ] |
Post subject: | Re: Opening Craft Doors with Lua |
You wanted to eject inventory? Use self:DropAllInventory() |
Author: | CaveCricket48 [ Mon Dec 07, 2009 1:17 am ] |
Post subject: | Re: Opening Craft Doors with Lua |
Ok, that works for opening the doors. Now how do I close them? |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |