Toribash
Original Post
Lua leave_game hook bug
e: Sorry, my mistake. I found the line "Lua script error: data/script/startup.lua:38: C stack overflow" several times in stderr.txt. I guess loading a new replay triggers the leave_game hook again.

I encountered some strange behavior when trying to load random replays:

Run following script:
Lua code:
math.randomseed(os.time()*math.random()) -- btw randomseed(os.time()) doesn't seem to work
local files=get_files("replay", "rpl")
run_cmd("lr "..files[math.random(#files)])
add_hook("leave_game", "selectReplay", function() run_cmd("lr "..files[math.random(#files)]) end)


Result:
1. Loads random replay.
2. When replay is finished, TB freezes.
3. After quite some time it comes back to life.
4. Go to 1.

If you replace leave_game by key_down it works perfecly fine.

btw: Happens on 3.91 as well as on 3.94. Don't think it matters but I'm running Windows Vista x86.
Last edited by psycore; Dec 18, 2011 at 08:26 PM.
Signature temporarily out of order.