Hi..
I now have a problem with a few scripts from my mystic pack. In my opinion, these still worked when I published the pack. But nothing works, or it may never have been right. I have no idea how I can solve the problem. I know what I want, but I can not do it.
I have a trap there, which becomes active when I approach. I also have a switch that should disable the trap and also reactivate it. But he does not.
Here is the script for the trap
local spear_flag = {}
function speartrap2_init (e)
spear_flag[e] = 0
end
function speartrap2_main (e)
PlayerDist = GetPlayerDistance (e)
if GetPlayerDistance(e) < 300 then
if spear_flag[e] == 0 then
SetAnimation(0)
LoopAnimation(e)
g_Entity[e]['animating'] = 1
LoopSound (e,0)
ActivateIfUsed (e)
spear_flag[e] = 1
else
SetSoundVolume(100-(PlayerDist/200))
end
else
if GetAnimationFrame(e) == 0 then
StopAnimation(e)
StopSound(e)
spear_flag[e] = 0
end
end
if PlayerDist<80 then
HurtPlayer(e,1)
end
end
..and here for the switch.
g_switch = {}
function spearswitch_init(e)
g_switch[e] = "on"
end
function spearswitch_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 100 and g_PlayerHealth > 0 then
if g_switch[e]=="on" then
Prompt ( "Press E to deactivate this trap" )
if g_KeyPressE == 1 then
g_switch[e] = "offing"
SetAnimation(0)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
SetActivated(e,0)
end
end
if g_switch[e]=="off" then
Prompt ( "Press E to activate this trap" )
if g_KeyPressE == 1 then
g_switch[e] = "oning"
SetAnimation(0)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
SetActivated(e,1)
end
end
end
if g_KeyPressE == 0 then
if g_switch[e]=="oning" then
g_switch[e] = "on"
end
if g_switch[e]=="offing" then
g_switch[e] = "off"
end
end
end
I know it's very unstructured, but I can not do it better
Any constructive help is welcome
Andreas