New style of scripting for better complex menus.

This commit is contained in:
Filip Maj
2016-06-17 23:17:24 -04:00
parent cdf4b3a2f2
commit 4e69022072
8 changed files with 170 additions and 58 deletions

View File

@@ -181,6 +181,11 @@ namespace FFXIVClassic_Map_Server.Actors
return BasePacket.CreatePacket(propPacketUtil.Done(), true, false);
}
public string GetUniqueId()
{
return uniqueIdentifier;
}
public uint GetActorClassId()
{
return actorClassId;
@@ -322,7 +327,7 @@ namespace FFXIVClassic_Map_Server.Actors
return lparams;
}
public void DoEventStart(Player player, EventStartPacket eventStart)
public Coroutine GetEventStartCoroutine(Player player)
{
Script parent = null, child = null;
@@ -331,31 +336,23 @@ namespace FFXIVClassic_Map_Server.Actors
if (File.Exists(String.Format("./scripts/unique/{0}/{1}/{2}.lua", zone.zoneName, className, uniqueIdentifier)))
child = LuaEngine.LoadScript(String.Format("./scripts/unique/{0}/{1}/{2}.lua", zone.zoneName, className, uniqueIdentifier));
if (parent == null)
if (parent == null && child == null)
{
LuaEngine.SendError(player, String.Format("ERROR: Could not find script for actor {0}.", GetName()));
return;
return null;
}
//Have to do this to combine LuaParams
List<Object> objects = new List<Object>();
objects.Add(player);
objects.Add(this);
objects.Add(eventStart.triggerName);
if (eventStart.luaParams != null)
objects.AddRange(LuaUtils.CreateLuaParamObjectList(eventStart.luaParams));
//Run Script
DynValue result;
Coroutine coroutine;
if (child != null && !child.Globals.Get("onEventStarted").IsNil())
result = child.Call(child.Globals["onEventStarted"], objects.ToArray());
coroutine = child.CreateCoroutine(child.Globals["onEventStarted"]).Coroutine;
else if (!parent.Globals.Get("onEventStarted").IsNil())
result = parent.Call(parent.Globals["onEventStarted"], objects.ToArray());
coroutine = parent.CreateCoroutine(parent.Globals["onEventStarted"]).Coroutine;
else
return;
return null;
return coroutine;
}
public void DoEventUpdate(Player player, EventUpdatePacket eventUpdate)