-- Door opens on approach and will close and stay sealed once player moves through (or away) gate_status = {} function dooronetimeopen_init(e) gate_status[e] = "closed" SwitchFlicked = 1 end function dooronetimeopen_main(e) PlayerDist = GetPlayerDistance(e) if PlayerDist < 200 then if SwitchFlicked == 1 then if gate_status[e] == "closed" then -- door is closed, so open if g_Entity[e]['animating'] == 0 then SetAnimation(0); PlayAnimation(e); g_Entity[e]['animating'] = 1; gate_status[e] = "open" PlaySound(e,0); StartTimer(e); end else if gate_status[e] == "open" then -- door collision off after 1 second if GetTimer(e)>1000 then CollisionOff(e); SwitchFlicked = 0 end end end else if PlayerDist < 100 and SwitchFlicked == 2 then Prompt("This door is now sealed forever") end end else if SwitchFlicked == 0 then --close door if g_Entity[e]['animating'] == 0 then SetAnimation(1); PlayAnimation(e); g_Entity[e]['animating'] = 1; gate_status[e] = "closed" PlaySound(e,1); CollisionOn(e); SwitchFlicked = 2 end end end end