Can someone please, please, tell me how to stop the random explosions when my tank is blown up? I need a way to shut off the thread loops when the first objective bomb ($bomb1) explodes. If I knew how this "while" statement worked, I could probably figure it out. What does that "!" thing do?
// --------------------------------------------
// "Bomb 1 Exploded"
// --------------------------------------------
bomb1_exploded local.bomb1:
while (local.bomb1.exploded != 1)
wait .1
iprintlnbold_noloc "Axis have destroyed the Sherman tank!"
$random_tankfire remove
$lulubelle_origin remove
end
I tryed this inside the loops:
if (local.bomb1.exploded != 1)
{
end
}
But, it didn't work.
I also tried assigning a local (local.tepos = 1) number to $bomb1 exploded thread and using an "if" statememnt with that, but that also didn't work.
Stopping looping threads
Moderator: Moderators
YES!!!!!!!!!!!!!!!
YES!!!!!!!!!!! I got the loops to stop and with no console errors!!!!
random_explode1:
wait (randomfloat 4 + 13)
if ($bomb1.exploded == 1)
{
goto end_random
}
$lulubelle_origin playsound tank_snd_fire2
$random_tankfire anim start
$random_explode1_origin playsound arty_leadinmp1
wait 1
$random_explode1 anim start
radiusdamage $random_explode1_origin 256 384
$random_tankfire anim stop
wait 5
goto random_explode1
end_random:
end
random_explode1:
wait (randomfloat 4 + 13)
if ($bomb1.exploded == 1)
{
goto end_random
}
$lulubelle_origin playsound tank_snd_fire2
$random_tankfire anim start
$random_explode1_origin playsound arty_leadinmp1
wait 1
$random_explode1 anim start
radiusdamage $random_explode1_origin 256 384
$random_tankfire anim stop
wait 5
goto random_explode1
end_random:
end
I think the key is that local.variablename defines a variable that is only available in the thread where it has been created. You can submit the local variable to another thread by adding it to the called thread like this:
yourthread local.variablename:
commands here
end
To create a variable that can be used by all threads in script you have to use level.variablename.
Excuse my English - I am German.
If I am wrong with my thoughts please teach me the truth - I am not a C++ coder.

yourthread local.variablename:
commands here
end
To create a variable that can be used by all threads in script you have to use level.variablename.
Excuse my English - I am German.
If I am wrong with my thoughts please teach me the truth - I am not a C++ coder.
Your statement was correct I think, but I'd want to add that MOHAA even allows threads to be used as a function, for example:
//----------------------------------------------------------
local.var = 5
local.vartimesten = waitthread vartimesten local.var
// sets local.vartimesten to the output value of the 'vartimesten' thread
// I think 'waitthread' is necessary, don't use 'thread'.
iprintln_noloc local.vartimesten // prints 50
vartimesten local.var:
local.vartimesten = local.var * 10
end local.vartimesten // outputs local.vartimesten
//----------------------------------------------------------
This same concept is used in global/makeArray.scr. It allows much better use of your script if you understand it.
//----------------------------------------------------------
local.var = 5
local.vartimesten = waitthread vartimesten local.var
// sets local.vartimesten to the output value of the 'vartimesten' thread
// I think 'waitthread' is necessary, don't use 'thread'.
iprintln_noloc local.vartimesten // prints 50
vartimesten local.var:
local.vartimesten = local.var * 10
end local.vartimesten // outputs local.vartimesten
//----------------------------------------------------------
This same concept is used in global/makeArray.scr. It allows much better use of your script if you understand it.
