-- 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' open = {} function door_auto_init(e) open[e] = 0 end function door_auto_main(e) PlayerDist = GetPlayerDistance(e) if open[e] == 0 then if PlayerDist < 150 and g_PlayerHealth > 0 then if g_Entity[e]['activated'] == 0 then if g_Entity[e]['haskey'] == -1 then SetActivated(e,1) else if g_Entity[e]['haskey'] == 1 then Prompt("Unlock the door?") if g_KeyPressE == 1 then SetActivated(e,1) end else Prompt("This door is locked") end end else if g_Entity[e]['activated'] == 1 then if g_Entity[e]['animating'] == 0 then StartTimer(e) SetAnimation(0) PlayAnimation(e) g_Entity[e]['animating'] = 1 SetActivated(e,2) ActivateIfUsed(e) PlaySound(e,0) end else if g_Entity[e]['activated'] == 2 then -- door collision off after 1 second if GetTimer(e) > 250 then CollisionOff(e) open[e] = 1 end end end end end else if GetPlayerDistance(e) > 180 then -- door is open if g_Entity[e]['activated'] == 2 then if g_Entity[e]['animating'] == 0 then StartTimer(e) SetAnimation(1) PlayAnimation(e) g_Entity[e]['animating'] = 1 SetActivated(e,1) PlaySound(e,1) end else if GetTimer(e) > 250 then CollisionOn(e) open[e] = 0 end end end end end