Add OnAnyProduction and OnSold lua triggers
This commit is contained in:
@@ -147,6 +147,13 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnProduction, func, Context);
|
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. " +
|
[Desc("Call a function when this player completes all primary objectives. " +
|
||||||
"The callback function will be called as func(Player player).")]
|
"The callback function will be called as func(Player player).")]
|
||||||
public void OnPlayerWon(Player player, LuaFunction func)
|
public void OnPlayerWon(Player player, LuaFunction func)
|
||||||
@@ -456,6 +463,13 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
GetScriptTriggers(discovered.PlayerActor).RegisterCallback(Trigger.OnPlayerDiscovered, func, Context);
|
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. " +
|
[Desc("Removes all triggers from this actor. " +
|
||||||
"Note that the removal will only take effect at the end of a tick, " +
|
"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.")]
|
"so you must not add new triggers at the same time that you are calling this function.")]
|
||||||
|
|||||||
@@ -421,7 +421,8 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
using (var a = producee.ToLuaValue(f.Context))
|
using (var a = producee.ToLuaValue(f.Context))
|
||||||
using (var b = produced.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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user