#1 Members - Reputation: 529
Posted 27 February 2012 - 07:35 PM
http://pgl.yoyo.org/luai/i/lua_sethook
However, the LUA_MASKLINE function description has one giant caveat in its description:
This event only happens while Lua is executing a Lua function.
I am not sure what this means, but the hook doesn't seem to get called in the manner I expect. If I had a script like below, I would expect the hook to be called after executing each line:
local a = 1 --hook executed!
local b = a + 1 --hook executed!
b = b + 2 --hook executed!
Is the functionality I want supported in Lua? Thanks.
Build mobile games with native code
#2 Marketplace Seller - Reputation: 8941
Posted 27 February 2012 - 10:44 PM
For optimization, if you routinely run the same lua script, you might want to pre-load and pre-compile the script portions using luaL_loadstring (I'm guessing - I've never done it before), to reduce the overhead of parsing the data before running it.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal
#3 Moderators - Reputation: 13533
Posted 28 February 2012 - 01:52 AM
However, the LUA_MASKLINE function description has one giant caveat in its description:
This event only happens while Lua is executing a Lua function.
To me, that caveat sounds like it's implying that when Lua calls into a C function, no callbacks will be triggered, but when it returns from the C function, it will.The line hook: is called when the interpreter is about to start the execution of a new line of code, or when it jumps back in the code (even to the same line). (This event only happens while Lua is executing a Lua function.)






