Just to reiterate, my file name is the same as what the lua file is inside the script. I actually copied pasted it from the script.
Here is the script
-- door_no_lock.lua
--
-- this script has no lock - make sure the door does not have a Use Key entry in editor
-- can open and close door
--
-- 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
-- player must be inside this distance to have access to door
nearDistance = 100;
-- door states
closed_locked = 0;
closed_unlocked = 1;
open_unlocked = 2;
-- door animations
door_open_anim = 0;
door_close_anim = 1;
-- want to use lock then set to 0
-- don't want to use lock set to 1
door_no_lock_Lock_not_required = 1;
function door_no_lock_main(e)
--{ start function code
-- compute the player distance from our door
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
-- is the player near our door
if PlayerDist < nearDistance then
if g_Entity[e]['activated'] == closed_locked then
-- door is closed and locked
if door_no_lock_Lock_not_required == 1 then
g_Entity[e]['activated'] = closed_unlocked;
else
if g_Entity[e]['haskey'] == 1 then
Prompt("The door is locked. Press E key to unlock door");
if g_KeyPressE == 1 and door_pressed == 0 then
Prompt("Door UNLOCKED");
g_Entity[e]['activated'] = closed_unlocked;
door_pressed = 1;
end
else
Prompt("The door is locked. Find a key to unlock door");
end
end
elseif g_Entity[e]['activated'] == closed_unlocked then
-- door is unlocked and closed
Prompt("Press E to open door");
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then
-- set the animation to door_open
SetAnimation(door_open_anim);
PlayAnimation(e);
g_Entity[e]['animating'] = 1;
g_Entity[e]['activated'] = open_unlocked;
-- play door open sound
PlaySound0(e);
CollisionOff(e);
door_pressed = 1;
end
elseif g_Entity[e]['activated'] == open_unlocked then
-- door is open
Prompt("Press E to CLOSE door");
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then
-- set the animation to door close
SetAnimation(door_close_anim);
PlayAnimation(e);
g_Entity[e]['animating'] = 1;
g_Entity[e]['activated'] = closed_unlocked;
PlaySound1(e);
CollisionOn(e);
door_pressed = 1;
end
end
-- end door state checks
end
-- end player distance test
-- state of the E key
-- if E is not being pressed then reset the door_pressed variable back to zero
if g_KeyPressE == 0 then
door_pressed = 0;
end
end
--} end function code
-- Close door
if PlayerDist < 100 then
if g_Entity[e]['activated'] == 1 then
Prompt("Press E to close");
if g_KeyPressE == 1 and door_pressed == 0 and g_Entity[e]['animating'] == 0 then
SetAnimation(1);
PlayAnimation(e);
g_Entity[e]['animating'] = 1;
g_Entity[e]['activated'] = 0;
PlaySound0(e);
CollisionOn(e);
door_pressed = 1;
end
end
end
-- Set door_pressed = 0 if E key =0
if g_KeyPressE == 0 then
door_pressed = 0;
end
-- End function
end
And a pic of my script folder.
[img]http://files.enjin.com/191696/FPSC-R/script folder.bmp[/img]
Does this rely on anything in the global file by chance?
Case: Antec 900, Mobo: Asus Sabertooth 990FX, CPU: AMD T1100 Thuban 6 core @3300 ghz stock settings, COOLER: Thermaltake Frio, MEM: G Skill Ripjaws X series DDR 3 @ 1866 9-10-9-28, HDD: 2 Western Digital caviar Black 750 Gb set in RAID 0, GPU: Saphire HD 6950 flashed with 6970 bios, PSU: Corsair CX750M, MS: Cyborg Rat 7, KB: Logitec G510, OS: Windows 7 home premium 64 bit.