These scripts should get you started. They will open the door while the player is standing on the "pressure plate". As soon the player steps away a countdown begins. When time runs out the door is closed.
The "plate" will use "pressure_plate.lua" and the door will use "pressure_plate_door.lua"
In "pressure_plate.lua" you MUST set "door_e_number" to the entity number of the door you wish to control(in the init section)
The time before the door closes can be set with "door_delay"(in the init section again)
https://www.youtube.com/watch?v=QYP62MQGWpo
pressure_plate.lua
function pressure_plate_init(e)
door_e_number = 1 -- entity number of the door to be controlled
door_delay = 3 -- delay time in seconds
triggered = 0
opened_time = 0
direction = 0
end
local current_time = os.clock
function pressure_plate_main(e)
PlayerDist = GetPlayerDistance(e)
if triggered == 0 and PlayerDist < 80 then -- open door when player stands on plate
triggered = 1
direction = 1
PlayAnimation(door_e_number)
PlaySound(door_e_number,0)
CollisionOff(door_e_number)
end
if triggered == 1 and PlayerDist < 90 then -- delay countdown until player steps off plate
opened_time = current_time()
end
if triggered == 1 and PlayerDist > 90 and opened_time+door_delay < current_time() then -- close door after delay time has passed
triggered = 0
direction = 0
PlayAnimation(door_e_number)
PlaySound(door_e_number,1)
CollisionOn(door_e_number)
end
end
pressure_plate_door.lua
function pressure_plate_door_init(e)
end
function pressure_plate_door_main(e)
SetAnimation(direction)
end
*You could probably do this better with timers, and possibly with a single script....
Windows 10 Home 64-bit / Intel i5 2500k @ 4.4Ghz + Asetek 510LC / Intel DP67DE / Intel 530 Series 240GB SSD / 12GB Kingston KVR 1333 / XFX Radeon R9 285 / Corsair TX 650 / Antec 300