Hey all
I have (with the help of OldPMan) adapted the default door.lua script to use for an animated canopy on a space craft model.
So far I have been able to get the animations and prompts working correctly, but the problem is that the canopy never gets collisions turned on again, which means the player can walk over the canopy as expected (like when it is closed), but once it has been opened\closed, the player can walk thru it.
Can someone spot what is missing\wrong in this script?
srcanopy_pressed = 0
function srcanopy_init(e)
end
function srcanopy_main(e)
PlayerDist = GetPlayerDistance(e)
if (PlayerDist < 160 ) and g_PlayerHealth > 0 then
if g_Entity[e]['activated'] == 0 then
if g_Entity[e]['haskey'] == -1 then
SetActivated(e,1)
else
if g_Entity[e]['haskey'] == 1 then
Prompt("E to use canopy access code")
if g_KeyPressE == 1 then
SetActivated(e,1)
end
else
Prompt("Access code required to activate the canopy")
end
end
else
if g_Entity[e]['activated'] == 1 then
-- canopy is closed
-- not animating, prompt player to open
if g_Entity[e]['animating'] == 0 then
Prompt("E to open canopy")
end
-- player pressed e, open canopy
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and srcanopy_pressed == 0 then
SetAnimation(0) -- opening animation
PlayAnimation(e)
g_Entity[e]['animating'] = 1
SetActivated(e,2)
ActivateIfUsed(e)
PlaySound(e,0)
StartTimer(e)
g_Entity[e]['timer'] = g_Time
srcanopy_pressed = 1
end
else
if g_Entity[e]['activated'] == 2 then
-- canopy is open
-- not animating, prompt player to close
if g_Entity[e]['animating'] == 0 then
Prompt("E to close canopy")
end
-- player pressed e, close the canopy
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and srcanopy_pressed == 0 then
SetAnimation(1) -- closing animation
PlayAnimation(e)
g_Entity[e]['animating'] = 1
SetActivated(e,1)
PlaySound(e,1)
CollisionOn(e)
srcanopy_pressed = 1
end
end
end
end
end
if g_Entity[e]['activated'] == 2 then
-- door collision off after 1 second
if GetTimer(e)>1000 then
CollisionOff(e)
end
end
if g_KeyPressE == 0 then
srcanopy_pressed = 0
end
--PromptLocal ( e, "activated=" .. g_Entity[e]['activated'] .. "PlayerDist=" .. PlayerDist .. " plrvisible=" .. g_Entity[e]['plrvisible'] .. " haskey=" .. g_Entity[e]['haskey'] )
PromptLocal ( e, "is activated=" .. g_Entity[e]['activated'] .. " is anmimating = " .. g_Entity[e]['animating'] )
end
Reliquia....
Intel(R) Core(TM) i3-4160 @ 3,60GHz. 8GB Ram. NVidia GeForce GTX 750. Acer 24" Monitors x 2 @ 1920 x 1080. Windows 10 Pro 64-bit.