I found the relevant commands in the 'LUA Scripting commands and structure' thread, but it's not working for me. I'm guessing that I've got the entity index wrong. With the script that I made, the entity is supposed to animate when you get within a certain distance, and then move. I also included a prompt ("working") so that I could see roughly what's happening. However, when I get within the required distance, the "working" prompt appears, but the animation only plays when leave the area.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Door Prompts 'Closed' can be opened
function character2_init(e)
end
function character2_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));
if PlayerDist < 500 then
SetAnimation(0);
LoopAnimation(e);
Prompt("Working");
MoveForward(e,100);
end
end