public static void RegisterLUAFunctions(ScriptEngine state) { state.RegisterFunction("debuginfo", typeof(luaFuncs).GetMethod("lua_debuginfo")); state.RegisterFunction("mlook", typeof(luaFuncs).GetMethod("lua_mlook")); state.RegisterFunction("freelook", typeof(luaFuncs).GetMethod("lua_freelook")); state.RegisterFunction("noclip", typeof(luaFuncs).GetMethod("lua_noclip")); state.RegisterFunction("cam_distance", typeof(luaFuncs).GetMethod("lua_cam_distance")); state.RegisterFunction("timescale", typeof(luaFuncs).GetMethod("lua_timescale")); }
public static void Res_CreateEntityFunc(ScriptEngine lua, string func_name, int entity_id) { if(((LuaTable)lua["entity_funcs"])[entity_id] == null) lua.DoString("entity_funcs[" + entity_id + "] = {}"); ((LuaFunction) lua[func_name + "_init"]).Call(entity_id); }
public static void InitConfig(string filename) { InitDefaultGlobals(); if(!string.IsNullOrWhiteSpace(filename) && FileFound(filename)) { var state = new ScriptEngine(); state.RegisterC("bind", typeof(MainEngine).GetMethod("BindKey")); // get and set key bindings try { state.DoFile(filename); } catch(Exception e) { Sys.DebugLog(LUA_LOG_FILENAME, "{0}", e.Message); return; } state.ParseScreen(Global.ScreenInfo); state.ParseRender(Renderer.Settings); #if !NO_AUDIO state.ParseAudio(Global.AudioSettings); #endif state.ParseConsole(ConsoleInfo.Instance); state.ParseControls(ControlMapper); state.ParseSystem(Global.SystemSettings); } else { Sys.Warn("Could not find \"{0}\"", filename); } }