Checks and fixes for lua.

This commit is contained in:
Filip Maj 2017-03-20 21:51:43 -04:00
parent 7c25b14640
commit 0a94840419
5 changed files with 33 additions and 10 deletions

View file

@ -147,6 +147,11 @@ namespace FFXIVClassic_Map_Server.lua
private List<LuaParam> CallLuaFunctionNpcForReturn(Player player, Npc target, string funcName, params object[] args)
{
object[] args2 = new object[args.Length + 2];
Array.Copy(args, 0, args2, 2, args.Length);
args2[0] = player;
args2[1] = target;
LuaScript parent = null, child = null;
if (File.Exists("./scripts/base/" + target.classPath + ".lua"))
@ -173,9 +178,9 @@ namespace FFXIVClassic_Map_Server.lua
DynValue result;
if (child != null && child.Globals[funcName] != null)
result = child.Call(child.Globals[funcName], this);
result = child.Call(child.Globals[funcName], args2);
else if (parent != null && parent.Globals[funcName] != null)
result = parent.Call(parent.Globals[funcName], this);
result = parent.Call(parent.Globals[funcName], args2);
else
return null;
@ -218,7 +223,7 @@ namespace FFXIVClassic_Map_Server.lua
if (child != null && !child.Globals.Get(funcName).IsNil())
coroutine = child.CreateCoroutine(child.Globals[funcName]).Coroutine;
else if (parent.Globals.Get(funcName) != null && !parent.Globals.Get(funcName).IsNil())
else if (parent != null && parent.Globals.Get(funcName) != null && !parent.Globals.Get(funcName).IsNil())
coroutine = parent.CreateCoroutine(parent.Globals[funcName]).Coroutine;
if (coroutine != null)