BUG: replay file cannot be played in latest svn
Posted: 07 Feb 2013, 17:25
When you click the replay button the game just start in normal mode
Open source game community & development
http://forum.freegamedev.net/
acme_pjz {l Wrote}:I added an additional 'reset()' which erased the level record Still investigating how to fix that because in order to let script environment get reset we should call 'reset()' when record play starts or rewinds, so there will be more added 'reset()' calls later...
Edward_Lii {l Wrote}:I think it would be best if we handled the onCreate scripts in the loadLevelFromNode method
Edward_Lii {l Wrote}:The best solution would be IMHO to somehow save the complete lua_State and the box locations.
However, this won't work when scripts can remove/create gameobjects.
acme_pjz {l Wrote}:No, it doesn't work At first I tried it before committing svn r568 and found that the onCreate script doesn't work properly because the old code 'currentState=new Game();' call the 'Game::Game()' then call 'Game::loadLevelFromNode()' then call the onCreate script, before Game::Game() returns. So 'currentState' is still NULL, and script code querying the game state won't work because it can't find the pointer point to Game object IMHO the best solution is yours (i.e. code before svn r568), but we shouldn't load any level or record in the constructor, we should load level after the class initialized and 'currentState' has a correct value, i.e. remove the 'loadLevel' parameter in the constructor.
acme_pjz {l Wrote}:Is there any function in Lua to duplicate the complete lua_State?
Edward_Lii {l Wrote}:[...] For the replay to work the scriptexecutor has to be reset and the onCreate scripts need to be executed.
This could be added to the replayPlay method, but that means we have the same code in three different places, which feels a bit bad.
Edward_Lii {l Wrote}:Not that I could find, that's why I added the word "somehow".
Still I think it's the best solution, maybe we can use environments for this?