lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Could you model your script as a state machine and simply save the game state (and any substates)? Then you could feed these states back to the script on startup and it can resume where it left off prior to the save.

Seems simpler than trying to persist and restore the internal VM state of the script itself. It would also decouple your game state from the scripting technology you're using (in case you choose to use something other than Lua in the future).

-Brian


-----Original Message-----
From: Krzysztof Jakubowski [mailto:kjakubowski@city-interactive.com]
Sent: Thursday, May 06, 2004 4:28 PM
To: Lua list
Subject: Re: lua state


Thanks for your answer. You are right. But on the other hand I must make
savegames in my game :) I must save the state of almost all game objects and
also the "position of script execution". This is becouse scripts in my game
are not only event-based. Each mission/level has its own script. The main
action goes linearly and so does the script. When script must wait for
something then its execution is stopped using lua_yeild / lua_resume.

Probably I don't need to save the whole state. I can save only globals. Then
I can just reload the original script and load saved globals. The problem is
that I don't want to execute the script from the beginning, but from the
place it was during saving :) It is also possible that it was in nested lua
function or in loop, so that it is not enought to jump to "line"... How to
do it? If the only way is to study hard lua source code, please give me some
hints :)

Thanks
Krzysiek