it wont appear to move if you are moving it forward and backwards by the same amount
Quote: " -- Move entity forward by 1000 units
MoveForward(e,1000)
-- Move entity backwards by 1000 units
MoveBackward(e,1000)"
you would need to add in some delay if you wanted a visual movement (and 1000 movement is a lot - if you consider how far away from an object you would be using
Quote: "if PlayerDist < 1000 then"
then you will get the idea of how far it'd move)
as for the health.. well the script is right so it's an issue with the FPE file, i never had much luck with this either but maybe try copying a complete (stock health entity) FPE file onto your objects FPE (and then update the quantity)?
edit: so your FPE works fine for me, you need to add in a timer for the movement and the HP decrease - currently HP drops really fast but i did update the sound for you
--Simple Trap script
-- Script will repeat infinitely so trap should continue to move back and fowards
local playing = 0
function trap_simple_01_main(e)
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));
-- Move entity forward by 1000 units
--MoveForward(e,1000)
-- Move entity backwards by 1000 units
--MoveBackward(e,1000)
-- Start the if statement, only if the statement is true will the code under it run
-- In this case if player is closer then 100 units then statement is true
if PlayerDist < 100 then
if playing == 0 then
-- Tell reloaded to play sound 0 that we put on the entity
LoopSound(e,0)
playing = 1
end
--Adds player health from the FPE file in this case -100 health
-- Note at the moment player cannot dies from damage this way
AddPlayerHealth(e);
--End the if statement
else
playing = 0
StopSound(e,0)
end
--End the function
end
although if you wanted to only have HP drop each time the player steps on it or something (and not constantly) then you could move the AddPlayerHealth line up in with the loopsound part and change loopsound to playsound (note i also noticed that if you hit exactly 0 HP you do freeze (no player control).... this would be really handy for disabling player input if we could find a way of getting current player HP
--Simple Trap script
-- Script will repeat infinitely so trap should continue to move back and fowards
local playing = 0
function trap_simple_01_main(e)
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));
-- Move entity forward by 1000 units
MoveForward(e,1000)
-- Move entity backwards by 1000 units
MoveBackward(e,1000)
-- Start the if statement, only if the statement is true will the code under it run
-- In this case if player is closer then 100 units then statement is true
if PlayerDist < 100 then
if playing == 0 then
-- Tell reloaded to play sound 0 that we put on the entity
PlaySound(e,0)
playing = 1
--Adds player health from the FPE file in this case -100 health
-- Note at the moment player cannot dies from damage this way
AddPlayerHealth(e);
end
--End the if statement
else
playing = 0
StopSound(e,0)
end
--End the function
end
life's one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11