#include AHK-LUA-API.ahk
#include AHK-HOOK-API.ahk
global luaL_newstateHook := new Hook("lua51.dll", "luaL_newstate", "Hook_luaL_newstate", "CDecl")
Hook_luaL_newstate()
{
luaL_newstateHook.SetStatus(false)
retValue := luaL_newstate()
luaL_newstateHook.SetStatus(true)
lua_register(retValue, "MsgBox", "LUAFUNC_MsgBox")
lua_register(retValue, "MultiAdd", "LUAFUNC_Test")
return retValue
}
LUAFUNC_MsgBox(L)
{
MsgBox, % lua_tostring(L, 1)
return 0
}
LUAFUNC_Test(L)
{
sum := 0
n := lua_gettop(L)
loop % n
sum += lua_tonumber(L, A_Index)
lua_pushnumber(L, sum)
return 1
}