public LuaTestLogic( IScriptEventRuntime eventRuntime, LuaService luaService, CommandService commandService, ILogger logger ) { this.eventRuntime = eventRuntime; this.luaService = luaService; this.logger = logger; commandService.AddCommand("lua").Triggered += (source, args) => Init(); }
public void LoadInto(IScriptEventRuntime eventRuntime) { eventRuntime.RegisterEvent <Player>( "onPlayerWasted", (element, callback) => { void callbackProxy(Element sender, PedWastedEventArgs e) => callback.CallbackDelegate(e.Source); return(new EventHandlerActions <Player>() { Add = (element) => element.Wasted += callbackProxy, Remove = (element) => element.Wasted -= callbackProxy }); } ); }
public void LoadInto(IScriptEventRuntime eventRuntime) { eventRuntime.RegisterEvent <Element>( "onElementDestroyed", (element, callback) => { void callbackProxy(Element e) => callback.CallbackDelegate(e); return(new EventHandlerActions <Element>() { Add = (element) => element.Destroyed += callbackProxy, Remove = (element) => element.Destroyed -= callbackProxy }); } ); }
public LuaTestLogic(IScriptEventRuntime eventRuntime, LuaService luaService) { eventRuntime.LoadDefaultEvents(); luaService.LoadDefaultDefinitions(); luaService.LoadDefinitions <CustomMathDefinition>(); luaService.LoadDefinitions <TestDefinition>(); using FileStream testLua = File.OpenRead("test.lua"); using StreamReader reader = new StreamReader(testLua); try { luaService.LoadScript("test.lua", reader.ReadToEnd()); } catch (InterpreterException ex) { System.Console.WriteLine("Failed to load script\n\t{0}", ex.DecoratedMessage); } }
public EventScriptDefinitions(IScriptEventRuntime eventRuntime) { this.eventRuntime = eventRuntime; }