-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Door Prompts 'Closed' can be opened with entity collected specified by 'USE KEY' -- state to ensure user must release E key before can open/close again door_pressed = 0 doorlegacy = {} function doorlegacy_init(e) -- set entity for manual frame control CharacterControlLimbo(e) doorlegacy[e] = 0 end function doorlegacy_main(e) PlayerDist = GetPlayerDistance(e) if (PlayerDist < 100 ) and g_PlayerHealth > 0 then if 1 then if g_Entity[e]['activated'] == 0 then if g_Entity[e]['haskey'] == -1 then SetActivated(e,1) else if g_Entity[e]['plrvisible'] == 1 then if g_Entity[e]['haskey'] == 1 then if GetGamePlayerStateXBOX() == 1 then Prompt("The door is locked. Press Y button to unlock door") else Prompt("The door is locked. Press E key to unlock door") end if g_KeyPressE == 1 then SetActivated(e,1) end else Prompt("The door is locked. Find a key to unlock door") end end end else if g_Entity[e]['activated'] == 1 then -- door is unlocked and closed if GetGamePlayerStateXBOX() == 1 then Prompt("Press Y button to open door") else Prompt("Press E to open door") end if g_KeyPressE == 1 and door_pressed == 0 then doorlegacy[e] = 0 SetAnimationFrame(e,doorlegacy[e]) SetActivated(e,2) PlaySound(e,0) StartTimer(e) door_pressed = 1 end else if g_Entity[e]['activated'] == 3 then -- door is open if GetGamePlayerStateXBOX() == 1 then Prompt("Press Y button to close door") else Prompt("Press E to close door") end if g_KeyPressE == 1 and door_pressed == 0 then SetActivated(e,4) PlaySound(e,1) CollisionOn(e) door_pressed = 1 end end end end end end if g_Entity[e]['activated'] == 2 then doorlegacy[e] = doorlegacy[e] + 0.1 if GetAnimationFrame(e)>GetEntityAnimationFinish(e,0) then doorlegacy[e] = GetEntityAnimationFinish(e,0) CollisionOff(e) SetActivated(e,3) end SetAnimationFrame(e,doorlegacy[e]) end -- handle door closing frame animation if g_Entity[e]['activated'] == 4 then doorlegacy[e] = doorlegacy[e] - 0.1 if GetAnimationFrame(e)