I have been trying to sort a Script for an animated entity VCR
I have managed to get the script to eject the tape from the unit, but i'm stuck
on getting it to insert again but then stay in until you press E again.
I have script set so as to state 'Press E to Eject Tape'
This works just fine and the test shows up on screen.
But I have set a second command for Incert 'Press E to Insert Tape'
this text does not show up on screen when you press E again.
I someone could point me in the right direction and show me were
i am going wrong please.
I have added the script I have done so far
-- state to ensure user must release E key before can open/close again
vcr_pressed = 0
function vcr_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 < 80 then
if g_Entity[e]['activated'] == 0 then
-- vcr is closed
Prompt("Press E to Eject Tape")
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and vcr_pressed == 0 then
SetAnimation(0);
PlayAnimation(e)
g_Entity[e]['animating'] = 1
g_Entity[e]['activated'] = 1
PlaySound(e,0);
StartTimer(e)
vcr_pressed = 1
end
else
if g_Entity[e]['activated'] == 1 then
-- vcr collision off after 1 second
-- if GetTimer(e)>1000 then
-- CollisionOff(e)
-- end
-- vcr is open
Prompt("Press E to Insert Tape")
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and vcr_pressed == 1 then
SetAnimation(0)
PlayAnimation(e);
g_Entity[e]['animating'] = 1
g_Entity[e]['activated'] = 1
PlaySound(e,1);
CollisionOn(e);
vcr_pressed = 1
end
end
end
end
if g_KeyPressE == 1 then
vcr_pressed = 0
end
end