I'm trying to make a puzzle with several doors. How can I 'invert' doorremote.lua so that a door is open by default but closes once the player activates it? What I have so far sort of works, but not quite (the animation doesn't seem to be quite calling correctly and the collision doesn't want to work when the door is closed)
doorautolegacy = {}
function doorremote_inverted_init(e)
doorautolegacy[e] = 0
end
function doorremote_inverted_main(e)
Prompt ("Activated = "..(g_Entity[e]['activated']))
if g_Entity[e]['activated'] == 0 then
doorautolegacy[e] = GetEntityAnimationFinish(e,0)
SetAnimationFrame(e,doorautolegacy[e])
end
if g_PlayerHealth > 0 and g_Entity[e]['activated'] == 1 then
if g_Entity[e]['activated'] == 1 and GetAnimationFrame(e) == GetEntityAnimationFinish(e,0) then
SetActivated(e,2)
ActivateIfUsed(e)
PlaySound(e,1)
end
if g_Entity[e]['activated'] == 1 then
if GetAnimationFrame(e) == GetEntityAnimationStart(e,0) then
doorautolegacy[e] = GetEntityAnimationStart(e,0)
SetAnimationFrame(e,doorautolegacy[e])
SetActivated(e,4)
ActivateIfUsed(e)
PlaySound(e,0)
end
end
end
if g_Entity[e]['activated'] == 2 then
CollisionOff(e)
doorautolegacy[e] = doorautolegacy[e] - 0.5
if GetAnimationFrame(e)<GetEntityAnimationStart(e,0) then
doorautolegacy[e] = GetEntityAnimationStart(e,0)
SetActivated(e,3)
end
SetAnimationFrame(e,doorautolegacy[e])
CollisionOn(e)
end
if g_Entity[e]['activated'] == 4 then
CollisionOff(e)
doorautolegacy[e] = doorautolegacy[e] + 0.5
if GetAnimationFrame(e)==GetEntityAnimationFinish(e,0) then
doorautolegacy[e] = GetEntityAnimationFinish(e,0)
CollisionOn(e)
SetActivated(e,0)
end
SetAnimationFrame(e,doorautolegacy[e])
end
end
Secondly, is there a way to use multiple switches to open multiple doors? (e.g. switch A activates doors A and B, switch B activates doors B and C, switch C activates doors A and C?)
AE