Add a damage parameter to Lua OnDamage callback
This commit is contained in:
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when the actor is damaged. The callback " +
|
[Desc("Call a function when the actor is damaged. The callback " +
|
||||||
"function will be called as func(Actor self, Actor attacker).")]
|
"function will be called as func(Actor self, Actor attacker, int damage).")]
|
||||||
public void OnDamaged(Actor a, LuaFunction func)
|
public void OnDamaged(Actor a, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnDamaged, func, Context);
|
GetScriptTriggers(a).RegisterCallback(Trigger.OnDamaged, func, Context);
|
||||||
|
|||||||
@@ -118,7 +118,8 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var b = e.Attacker.ToLuaValue(f.Context))
|
using (var b = e.Attacker.ToLuaValue(f.Context))
|
||||||
f.Function.Call(f.Self, b).Dispose();
|
using (var c = e.Damage.Value.ToLuaValue(f.Context))
|
||||||
|
f.Function.Call(f.Self, b, c).Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user