Howdy people!
I am trying to make a very simple script that will allow a small amount of text to appear at the bottom of the screen to serve as information whent eh player is near something or needs to do something.
Here is what I have so far (I took the basis of the script from someone else - can't remember where I got it from though......)
-- Display Entity Text
function display_candles_main(e)
-- math for player distance, this is always the same
-- Put it into any script where you want to have it based on distance to player
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));
-- Detect if player is close enough to display the prompt
-- Increase the number to increase the distance you can be from the object
if PlayerDist < 100 then
--Now to display the text and variables
Prompt ("How are these candles lit? I thought this was abandoned")
-- End the if statement
end
if PlayerDist > 100 then
Destroy(e)
end
-- End the function
end
What I want to happen, is when the player moves away from the candles I want the text to disappear and never appear again.
I initially tried to add Destroy(e) a the end, but, this obviously destroyed the candle entity. Then I thought, I could use a smaller entity behind the candles, as it wouldn't matter if that was destroyed. But, the trouble is, it was destroyed straight away. So, I added the little bit at the end that checks if the player is far enough away from the entity before it destroys it......obviously, the player starts far enough away, so, its destroyed before I even get there!
Any help on this would be great!
Also, has anyone worked on any scripts that would allow the doors to close automatically if the player is far enough away?
Cheers
Jay.