|
FAQ
• Search • Login
|
|
Page 1 of 1
|
[ 8 posts ] |
|
Opening Craft Doors with Lua
Author |
Message |
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
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.
|
Fri Dec 04, 2009 11:59 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Opening Craft Doors with Lua
Set state to PRIMARY_ACTION that should work.
|
Sat Dec 05, 2009 5:59 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
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
|
Sun Dec 06, 2009 1:57 am |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
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);
|
Sun Dec 06, 2009 2:12 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
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.
|
Sun Dec 06, 2009 2:37 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Opening Craft Doors with Lua
Setting it twice within one sim update probably just makes it never flipflop.
|
Sun Dec 06, 2009 8:03 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Opening Craft Doors with Lua
You wanted to eject inventory? Use self:DropAllInventory()
|
Sun Dec 06, 2009 7:37 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Opening Craft Doors with Lua
Ok, that works for opening the doors. Now how do I close them?
|
Mon Dec 07, 2009 1:17 am |
|
|
|
|
Page 1 of 1
|
[ 8 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
|
|