well i made it work using 3 scripts, definitely not the 1 you were aiming for but if you dont want the door to close you can ignore the 3rd
the main issue i found is that you can't control a specific entity's animation (there's no e value in the command) therefore i couldnt make the door animate directly from the prompt (desk) so it was easier just to make the door code much smaller and make it open as soon as u press E for the clearance.
so u apply this to the zone at the desk
continue.lua
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
--smallg
function continue_init(e)
end
local pressed = 0
clearance = 0
function continue_main(e)
if g_Entity[e]['plrinzone']==1 then
Prompt ("Do you have required clearance to continue?");
if g_KeyPressE == 1 and pressed == 0 then
clearance = 1
pressed = 1
end
if clearance == 1 then
Prompt("You may proceed but be cautious.");
end
end
if g_KeyPressE == 0 then
pressed = 0
end
end
this to the door
--smallg
function continue_door_init(e)
end
function continue_door_main(e)
if clearance == 1 then
if g_Entity[e]['activated'] == 0 then
SetAnimation(0);
PlayAnimation(e);
g_Entity[e]['activated'] = 2;
PlaySound(e,0);
CollisionOff(e)
end
elseif clearance == 0 then
if g_Entity[e]['activated'] == 2 then
SetAnimation(1);
PlayAnimation(e);
g_Entity[e]['activated'] = 0;
PlaySound(e,1);
CollisionOn(e);
end
end
end
and if u want the door to close set this to a trigger zone behind the door (it will also let you back out again currently - wasnt sure if you wanted that or not)
--smallg
function close_door_trigger_init(e)
end
local triggered = 0
function close_door_trigger_main(e)
if g_Entity[e]['plrinzone']==1 then
if triggered == 0 then
triggered = 1
if clearance == 0 then
clearance = 1 --remove this line if u want door to stay closed
elseif clearance == 1 then
clearance = 0
end
end
else
triggered = 0
end
end
if you dont want to get back out (i.e. door will remain closed just remove the line clearance = 1
not really much better than doing it the normal way but it should help improve the distance checks
life's one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11