Skip to content
User Avatar
#2226
Auto-translated
RedHeavenHero

local threads = {}

local startExec = function(func)
local threads = threads
errorHook(function()
%threads[%func] = nil
end)
threads[func] = 1
func()
threads[func] = nil
end

function startThreadOnce(func)
if not %threads[func] then
startThread(%startExec, func)
end
end

function isFunctionRunning(func)
return %threads[func]
end
In this example, startThreadOnce starts the function only if it is not already running. isFunctionRunning checks if the function is currently running.
Thank you. If the function throws an error, will it transition to a completed status?
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...