Convert Lua array-like structures to use named entries

This commit is contained in:
atlimit8
2015-10-18 15:14:11 -05:00
parent c87c2270ca
commit f79ac636f2
18 changed files with 265 additions and 267 deletions

View File

@@ -11,14 +11,13 @@ IdlingUnits = function()
end)
end
BaseBuildings =
{
{ "apwr", CVec.New(5, -9), 500, true },
{ "tent", CVec.New(-4, -4), 400, true },
{ "proc", CVec.New(0, -8), 1400, true },
{ "weap", CVec.New(-4, -8), 2000, true },
{ "apwr", CVec.New(6, -5), 500, true }
}
BaseApwr = { type = "apwr", pos = CVec.New(5, -9), cost = 500, exists = true }
BaseTent = { type = "tent", pos = CVec.New(-4, -4), cost = 400, exists = true }
BaseProc = { type = "proc", pos = CVec.New(0, -8), cost = 1400, exists = true }
BaseWeap = { type = "weap", pos = CVec.New(-4, -8), cost = 2000, exists = true }
BaseApwr2 = { type = "apwr", pos = CVec.New(6, -5), cost = 500, exists = true }
BaseBuildings = { BaseApwr, BaseTent, BaseProc, BaseWeap, BaseApwr2 }
BuildBase = function()
if CYard.IsDead or CYard.Owner ~= enemy then
@@ -28,7 +27,7 @@ BuildBase = function()
end
for i,v in ipairs(BaseBuildings) do
if not v[4] then
if not v.exists then
BuildBuilding(v)
return
end
@@ -38,12 +37,12 @@ BuildBase = function()
end
BuildBuilding = function(building)
Trigger.AfterDelay(Actor.BuildTime(building[1]), function()
local actor = Actor.Create(building[1], true, { Owner = enemy, Location = CYardLocation.Location + building[2] })
enemy.Cash = enemy.Cash - building[3]
Trigger.AfterDelay(Actor.BuildTime(building.type), function()
local actor = Actor.Create(building.type, true, { Owner = enemy, Location = CYardLocation.Location + building.pos })
enemy.Cash = enemy.Cash - building.cost
building[4] = true
Trigger.OnKilled(actor, function() building[4] = false end)
building.exists = true
Trigger.OnKilled(actor, function() building.exists = false end)
Trigger.OnDamaged(actor, function(building)
if building.Owner == enemy and building.Health < building.MaxHealth * 3/4 then
building.StartBuildingRepairs()