When using keypress you need to
1) stop the code executing once it's done (using pressed=1) and
2) check for keyup. If it is, reset pressed to 0 for next time a key is pressed.
Here's an example. If you step through it you'll see that once "e" is tapped, pressed becomes "1" and the code cannot execute again until the "e" is lifted and pressed is reset. Because "pressed == 0 " is false the call to execute is prevented. When pressed is 0 and "e" is
not pressed the code cannot execute either.
function stuff_init(e)
pressed = 0
end
function stuff_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 250 then
Prompt ( "Press E to pick up Key" )
-- Prompt ( "Press E to open chest" )
if GetInKey() == "e" and pressed == 0 then
pressed = 1
-- *****
-- do your stuff here
-- *****
end
if GetInKey() == "" then
pressed = 0
end
end
It's a good idea to include your script (use code tags) when you have problems and then we can often make the correction in your own code so you can C&P it back.
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD