lua-users home
lua-l archive

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


If the line hook actually does get called each line, then I will spend some more time on it and report my results.  I couldn't tell if it only got executed when on a line when a function call is made, or what.  Obviously it wouldn't be able to step through your C code, so I am not sure why they added that ambiguous caveat in the description.

Best Regards,

Josh Klint
CEO
Leadwerks Software

On Feb 27, 2012, at 6:38 PM, Geoff Leyland wrote:

On 28/02/2012, at 2:22 PM, Josh Klint wrote:

I am looking for a way to call my own C++ function automatically at the end of each line in a Lua script.  The Lua SetHook function seems to do this:
http://pgl.yoyo.org/luai/i/lua_sethook

However, the HOOK_MASKLINE function description has one giant caveat in its description:
(This event only happens while Lua is executing a Lua function.)

What problem do you see with this caveat?  Is it that you would like to have your hook called after each line of code in a C function?

I am not sure what this means, but the hook doesn't seem to get called in the manner I expect.

How, then, *does* the hook seem to get called?

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?

Yes.  This is what the line hook does (technically it's called *before* the line, but it's much the same).  Could you post some code?

Cheers,
Geoff