That works, but in recent versions of Spring you can also use any Lua object for your signals. That way you can simply set each signal to a unique empty table object, allowing for an unlimited amount of signals (instead of only 24).zwzsg wrote:The name of the signal doesn't matter at all. However it's very important that each signal is a power of 2 distinct from other signals (Do you speak binary? Ever worked with bitfields?)
You inverted Signal and SetSignalMask. You want to kill previous instance of my_script, not yourself! And don't forget to assign some 2^n number to a_custom_signal_to_kill_the_myscript_tread.Code: Select all
local function my_script() SetSignalMask( a_custom_signal_to_kill_the_myscript_tread ) Signal( a_custom_signal_to_kill_the_myscript_tread ) Spring.Echo('Executing my script') end
Then what I'm saying is from Cob, I assume it's the same for Lua unit scripts but I never tried.
Essentially if you use this you can see SetSignalMask as setting the name of the thread and Signal stopping all the threads with the given name.