Add CPos.New etc functions to Lua standard library and helpers to LuaScriptInterface.cs. Rename Team.Create to Team.New.
This commit is contained in:
@@ -24,7 +24,7 @@ Actor.Move = function(actor, location)
|
||||
end
|
||||
|
||||
Actor.MoveNear = function(actor, location, nearEnough)
|
||||
actor:QueueActivity(OpenRA.New("Move", { location, Map.GetWRangeFromCells(nearEnough) }))
|
||||
actor:QueueActivity(OpenRA.New("Move", { location, WRange.FromCells(nearEnough) }))
|
||||
end
|
||||
|
||||
Actor.ScriptedMove = function(actor, location)
|
||||
@@ -35,6 +35,10 @@ Actor.Teleport = function(actor, location)
|
||||
actor:QueueActivity(OpenRA.New("SimpleTeleport", { location }))
|
||||
end
|
||||
|
||||
Actor.AttackMove = function(actor, location)
|
||||
Internal.AttackMove(actor, location)
|
||||
end
|
||||
|
||||
Actor.HeliFly = function(actor, position)
|
||||
actor:QueueActivity(OpenRA.New("HeliFly", { position }))
|
||||
end
|
||||
@@ -119,6 +123,10 @@ Actor.Facing = function(actor)
|
||||
return Actor.Trait(actor, "IFacing"):get_Facing()
|
||||
end
|
||||
|
||||
Actor.IsIdle = function(actor)
|
||||
return actor.IsIdle
|
||||
end
|
||||
|
||||
Actor.SetStance = function(actor, stance)
|
||||
Internal.SetUnitStance(actor, stance)
|
||||
end
|
||||
@@ -135,6 +143,14 @@ Actor.OnRemovedFromWorld = function(actor, eh)
|
||||
Actor.Trait(actor, "LuaScriptEvents").OnRemovedFromWorld:Add(eh)
|
||||
end
|
||||
|
||||
Actor.ActorsWithTrait = function(className)
|
||||
local ret = { }
|
||||
for item in Utils.Enumerate(Internal.ActorsWithTrait(className)) do
|
||||
table.insert(ret, item.Actor)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
Actor.HasTrait = function(actor, className)
|
||||
return Internal.HasTrait(actor, className)
|
||||
end
|
||||
|
||||
@@ -4,6 +4,44 @@ Map.GetFacing = function(vec, currentFacing)
|
||||
return Internal.GetFacing(vec, currentFacing)
|
||||
end
|
||||
|
||||
Map.GetWRangeFromCells = function(cells)
|
||||
return Internal.GetWRangeFromCells(cells)
|
||||
end
|
||||
Map.GetRandomCell = function()
|
||||
return Internal.GetRandomCell()
|
||||
end
|
||||
|
||||
Map.GetRandomEdgeCell = function()
|
||||
return Internal.GetRandomEdgeCell()
|
||||
end
|
||||
|
||||
CPos.New = function(x, y)
|
||||
return OpenRA.New("CPos", { { x, "Int32" }, { y, "Int32" } })
|
||||
end
|
||||
|
||||
WPos.New = function(x, y, z)
|
||||
if z == nil then
|
||||
z = 0
|
||||
end
|
||||
return OpenRA.New("WPos", { { x, "Int32" }, { y, "Int32" }, { z, "Int32" } })
|
||||
end
|
||||
|
||||
WPos.FromCPos = function(location)
|
||||
return WPos.New(location.X * 1024, location.Y * 1024, 0)
|
||||
end
|
||||
|
||||
CVec.New = function(x, y)
|
||||
return OpenRA.New("CVec", { { x, "Int32" }, { y, "Int32" } })
|
||||
end
|
||||
|
||||
WVec.New = function(x, y, z)
|
||||
if z == nil then
|
||||
z = 0
|
||||
end
|
||||
return OpenRA.New("WVec", { { x, "Int32" }, { y, "Int32" }, { z, "Int32" } })
|
||||
end
|
||||
|
||||
WRange.New = function(r)
|
||||
return OpenRA.New("WRange", { { r, "Int32" } })
|
||||
end
|
||||
|
||||
WRange.FromCells = function(cells)
|
||||
return WRange.New(cells * 1024)
|
||||
end
|
||||
|
||||
@@ -23,8 +23,8 @@ Mission.MissionOver = function(winners, losers, setWinStates)
|
||||
end
|
||||
|
||||
Mission.GetGroundAttackersOf = function(player)
|
||||
return Utils.EnumerableWhere(World.Actors, function(actor)
|
||||
return not Actor.IsDead(actor) and Actor.IsInWorld(actor) and Actor.Owner(actor) == player and Actor.HasTrait(actor, "AttackBase") and Actor.HasTrait(actor, "Mobile")
|
||||
return Utils.Where(Actor.ActorsWithTrait("AttackBase"), function(actor)
|
||||
return not Actor.IsDead(actor) and Actor.IsInWorld(actor) and Actor.Owner(actor) == player and Actor.HasTrait(actor, "Mobile")
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -33,10 +33,18 @@ OpenRA.GetPlayer = function(internalName)
|
||||
return Utils.EnumerableFirstOrNil(World.Players, function(p) return p.InternalName == internalName end)
|
||||
end
|
||||
|
||||
OpenRA.GetPlayers = function(func)
|
||||
return Utils.EnumerableWhere(World.Players, func)
|
||||
end
|
||||
|
||||
OpenRA.SetWinState = function(player, winState)
|
||||
Internal.SetWinState(player, winState)
|
||||
end
|
||||
|
||||
OpenRA.GetRandomInteger = function(low, high)
|
||||
return Internal.GetRandomInteger(low, high)
|
||||
end
|
||||
|
||||
OpenRA.TakeOre = function(player, amount)
|
||||
Actor.Trait(player.PlayerActor, "PlayerResources"):TakeOre(amount)
|
||||
end
|
||||
@@ -67,4 +75,4 @@ end
|
||||
|
||||
OpenRA.GetCash = function(player)
|
||||
return Actor.Trait(player.PlayerActor, "PlayerResources").Cash
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Team = { }
|
||||
|
||||
Team.Create = function(actors)
|
||||
Team.New = function(actors)
|
||||
local team = { }
|
||||
team.Actors = actors
|
||||
team.OnAllKilled = { }
|
||||
|
||||
Reference in New Issue
Block a user