diff --git a/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs index 983c7a6108..6c631624c6 100644 --- a/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs @@ -147,6 +147,13 @@ namespace OpenRA.Mods.Common.Scripting GetScriptTriggers(a).RegisterCallback(Trigger.OnProduction, func, Context); } + [Desc("Call a function when any actor produces another actor. The callback " + + "function will be called as func(Actor producer, Actor produced, string productionType).")] + public void OnAnyProduction(LuaFunction func) + { + GetScriptTriggers(Context.World.WorldActor).RegisterCallback(Trigger.OnOtherProduction, func, Context); + } + [Desc("Call a function when this player completes all primary objectives. " + "The callback function will be called as func(Player player).")] public void OnPlayerWon(Player player, LuaFunction func) @@ -456,6 +463,13 @@ namespace OpenRA.Mods.Common.Scripting GetScriptTriggers(discovered.PlayerActor).RegisterCallback(Trigger.OnPlayerDiscovered, func, Context); } + [Desc("Call a function when this actor is sold. The callback function " + + "will be called as func(Actor self).")] + public void OnSold(Actor a, LuaFunction func) + { + GetScriptTriggers(a).RegisterCallback(Trigger.OnSold, func, Context); + } + [Desc("Removes all triggers from this actor. " + "Note that the removal will only take effect at the end of a tick, " + "so you must not add new triggers at the same time that you are calling this function.")] diff --git a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs index 2e01015a98..f4993e327c 100644 --- a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs +++ b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs @@ -421,7 +421,8 @@ namespace OpenRA.Mods.Common.Scripting { using (var a = producee.ToLuaValue(f.Context)) using (var b = produced.ToLuaValue(f.Context)) - f.Function.Call(a, b).Dispose(); + using (var c = productionType.ToLuaValue(f.Context)) + f.Function.Call(a, b, c).Dispose(); } catch (Exception ex) {