🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

LUA 5.0 - serialization of threads

Started by
-1 comments, last by Gray Flannel Armor 20 years, 6 months ago
Hi there! My question is not new on the forum and I''ve read all about it (from lua maillist too), but I don''t see right answer. I have a problem with serialization of my game. I have some objects in the game, that creates the same (simple) objects in LUA. Each objects have method next(), that executes every frame. Each next() is a coroutine. function tobject:next () while true do self:main() coroutine.yield() end end If I wanna create new object, I execute function create_object (name), that clones tobject, gives it the new name and creates new coroutine of method name.next. For example: create_object "lamp" creates new global object lamp, that have lamp:next() as new coroutine: ( lamp.next = coroutine.wrap (tobject.next) ) Each frame lamp:next () executes. If I create lamp:main() method, I can set behavior of object lamp. function lamp:main () self:waitfor (day) self:TurnOff () self:waitfor (night) self:TurnOn () end function lamp:waitfor (x) while not x do coroutine.yield() end end My question: how to save and restore such an objects? I can get traceback, but how to restore traceback? Thanks.

This topic is closed to new replies.

Advertisement