Added more Lua functions

This commit is contained in:
Curtis Shmyr
2014-08-15 19:51:02 -06:00
parent 780fd0df29
commit cb4bd52fc0
7 changed files with 140 additions and 4 deletions

View File

@@ -28,15 +28,18 @@ namespace OpenRA.Mods.RA.Scripting
}
[Desc("Returns a table of all actors within the requested region, filtered using the specified function.")]
public LuaTable ActorsInCircle(WPos location, WRange radius, LuaFunction filter)
public LuaTable ActorsInCircle(WPos location, WRange radius, LuaFunction filter = null)
{
var actors = context.World.FindActorsInCircle(location, radius)
.Select(a => a.ToLuaValue(context))
.Where(a =>
.Select(a => a.ToLuaValue(context));
if (filter != null)
actors = actors.Where(a =>
{
using (var f = filter.Call(a))
return f.First().ToBoolean();
});
return actors.ToLuaTable(context);
}
@@ -72,9 +75,13 @@ namespace OpenRA.Mods.RA.Scripting
public Actor NamedActor(string actorName)
{
Actor ret;
if (!sma.Actors.TryGetValue(actorName, out ret))
return null;
if (ret.Destroyed)
return null;
return ret;
}