public void Execute() { if (executionActions != null) { // Execute Lua code like in Furniture ( FurnitureActions ) GameEventActions.CallFunctionsWithEvent(executionActions.ToArray(), this); } if (!Repeat) { executed = true; } }
public void Update(float deltaTime) { int conditionsMet = 0; foreach (string precondition in preconditions) { // Call lua precondition it should return 1 if met otherwise 0 conditionsMet += (int)GameEventActions.CallFunction(precondition, this, deltaTime).Number; } if (conditionsMet >= preconditions.Count && executed == false && (MaxRepeats <= 0 || repeats < MaxRepeats)) { repeats++; Execute(); } }
public GameEventActions(string rawLuaCode) { // Tell the LUA interpreter system to load all the classes // that we have marked as [MoonSharpUserData] UserData.RegisterAssembly(); _Instance = this; myLuaScript = new Script(); // If we want to be able to instantiate a new object of a class // i.e. by doing SomeClass.__new() // We need to make the base type visible. myLuaScript.Globals["Inventory"] = typeof(Inventory); myLuaScript.Globals["Job"] = typeof(Job); // Also to access statics/globals myLuaScript.Globals["World"] = typeof(World); myLuaScript.DoString(rawLuaCode); }