Code: Select all
[C]: in function 'co_create'
[string "LuaGadgets/Gadgets/unit_script.lua"]:335: in function 'StartThread'
[string "scripts/csniper.lua"]:168: in function <[string "scripts/csniper.lua"]:164>
I experienced this error far to often so i did a little experiment on it. I put a StartThread into the StartMoving of the UnitScript. I got the error when i attempted to thread this function with StartThread(test1)
Code: Select all
function test1()
Spring.Echo("This is a global function")
a=1
if a==1 then
StartThread(test2)
Spring.Echo("Attempt to start a local function from a global one")
end
a=a+1
end
local function test2()
Spring.Echo("This is a local function")
i=1
if i==1 then
StartThread(test1)
Spring.Echo("Attempt to start a global function from a local one")
end
i=i+1
end
If is Threaded a local function - and from this one threaded the function. It worked perfectly.
Code: Select all
local function test1()
Spring.Echo("This is a global function")
a=1
if a==1 then
StartThread(test2)
Spring.Echo("Attempt to start a local function from a global one")
end
a=a+1
end
function test2()
Spring.Echo("This is a local function")
i=1
if i==1 then
StartThread(test1)
Spring.Echo("Attempt to start a global function from a local one")
end
i=i+1
end