/// <summary> /// Initializes global Lua state. /// </summary> private void InitializeLua() { _gL = Melua.luaL_newstate(); Melua.melua_openlib(_gL, new[] { new Melua.LuaLib("", Melua.meluaopen_basesafe), new Melua.LuaLib("table", Melua.luaopen_table), new Melua.LuaLib("string", Melua.luaopen_string), new Melua.LuaLib("math", Melua.luaopen_math), }); Melua.lua_atpanic(_gL, Melua.CreateFunctionReference(_gL, this.OnPanic)); this.RegisterFunctions(); }
/// <summary> /// Initializes global Lua state. /// </summary> private void InitializeLua() { GL = Melua.luaL_newstate(); Melua.melua_openlib(GL, LuaLib.BaseSafe, LuaLib.Table, LuaLib.String, LuaLib.Math); Melua.lua_atpanic(GL, Melua.CreateFunctionReference(GL, OnPanic)); // Functions // -------------------------------------------------------------- // Setup Register(addnpc); Register(addwarp); // Dialog Register(msg); Register(select); Register(close); Register(input); Register(numinput); Register(openshop); // Information Register(getpc); Register(getnpc); Register(gettime); // Inventory Register(hasitem); Register(countitem); Register(additem); Register(removeitem); // Action Register(warp); Register(resetstats); Register(changehair); Register(spawn); // Others Register(var); Register(logdebug); }
/// <summary> /// Initializes scripting environment. /// </summary> public void Initialize() { GL = Melua.luaL_newstate(); Melua.melua_openlib(GL, LuaLib.Table, LuaLib.String, LuaLib.Math); var func = new Melua.LuaNativeFunction(OnPanic); _functions.Add(func); Melua.lua_atpanic(GL, func); // Functions // -------------------------------------------------------------- // Output Register(print); Register(logdebug); // Setup Register(addnpc); Register(addwarp); // Dialog Register(msg); Register(select); Register(close); Register(input); Register(numinput); // Information Register(getpc); Register(getnpc); Register(gettime); // Inventory Register(hasitem); Register(countitem); // Action Register(warp); Register(resetstats); Register(changehair); Register(spawn); }