Add a number of small helper functions to Lua API

This commit is contained in:
Oliver Brakmann
2014-06-29 19:11:17 +02:00
parent d23707b5f7
commit 882f3f34c2
4 changed files with 68 additions and 7 deletions

View File

@@ -58,6 +58,17 @@ namespace OpenRA.Mods.RA.Scripting
return true;
}
[Desc("Skips over the first numElements members of the array and returns the rest")]
public LuaTable Skip(LuaTable table, int numElements)
{
var t = context.CreateTable();
for (var i = numElements; i <= table.Count; i++)
t.Add(t.Count + 1, table[i]);
return t;
}
[Desc("Returns a random value from table.")]
public LuaValue Random(LuaTable table)
{
@@ -94,5 +105,17 @@ namespace OpenRA.Mods.RA.Scripting
{
return context.World.Map.CenterOfCell(cell);
}
[Desc("Converts the number of seconds into game time (ticks).")]
public int Seconds(int seconds)
{
return seconds * 25;
}
[Desc("Converts the number of minutes into game time (ticks).")]
public int Minutes(int minutes)
{
return Seconds(minutes * 60);
}
}
}