gmod-module-base icon indicating copy to clipboard operation
gmod-module-base copied to clipboard

coroutines cause the generated modules to break

Open Python1320 opened this issue 11 years ago • 0 comments

The modules either crash or return incorrect values.

http://facepunch.com/showthread.php?t=1260809&p=42916561#post42916561

Example:

require'example' -- [url]https://github.com/garrynewman/gmod-module-base/blob/master/example/src/gm_example.cpp[/url]
local var
local thread = coroutine.create(function() 
   var = TestFunction(123,321)
   ErrorNoHalt(TestFunction())
   coroutine.yield()
   var = TestFunction()
end)
print("thread",thread) --thread thread: 0xd713a598
print("before",var) --before nil
--  321
print("resume",coroutine.resume(thread),coroutine.status(thread)) --  resume true suspended
print("now",var) -- now 321
print("should be",TestFunction(321)) -- should be Thanks for the number - I love 321.000000!!
print("resume",coroutine.resume(thread),coroutine.status(thread)) -- resume true dead
print("now",var) --  now -2.9528447354403e+111
print("should be",TestFunction()) -- should be This string is returned```

Python1320 avatar Nov 19 '13 20:11 Python1320