Skip to content

Commit 2f6e928

Browse files
committed
lua: updated gadgetHandler with AllowFeatureBuildStep
1 parent e087eed commit 2f6e928

File tree

1 file changed

+21
-8
lines changed
  • installer/builddata/springcontent/LuaGadgets

1 file changed

+21
-8
lines changed

installer/builddata/springcontent/LuaGadgets/gadgets.lua

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ gadgetHandler = {
6666
knownGadgets = {},
6767
knownCount = 0,
6868
knownChanged = true,
69-
69+
7070
GG = {}, -- shared table for gadgets
7171

7272
globals = {}, -- global vars/funcs
@@ -140,6 +140,7 @@ local callInLists = {
140140
'AllowUnitCreation',
141141
'AllowUnitTransfer',
142142
'AllowUnitBuildStep',
143+
'AllowFeatureBuildStep',
143144
'AllowFeatureCreation',
144145
'AllowResourceLevel',
145146
'AllowResourceTransfer',
@@ -244,20 +245,20 @@ function gadgetHandler:Initialize()
244245
local gadgetFiles = VFS.DirList(GADGETS_DIR, "*.lua", VFSMODE)
245246
-- table.sort(gadgetFiles)
246247

247-
for k,gf in ipairs(gadgetFiles) do
248-
Spring.Echo('gf1 = ' .. gf) -- FIXME
249-
end
248+
-- for k,gf in ipairs(gadgetFiles) do
249+
-- Spring.Echo('gf1 = ' .. gf) -- FIXME
250+
-- end
250251

251252
-- stuff the gadgets into unsortedGadgets
252253
for k,gf in ipairs(gadgetFiles) do
253-
Spring.Echo('gf2 = ' .. gf) -- FIXME
254+
-- Spring.Echo('gf2 = ' .. gf) -- FIXME
254255
local gadget = self:LoadGadget(gf)
255256
if (gadget) then
256257
table.insert(unsortedGadgets, gadget)
257258
end
258259
end
259260

260-
-- sort the gadgets
261+
-- sort the gadgets
261262
table.sort(unsortedGadgets, function(g1, g2)
262263
local l1 = g1.ghInfo.layer
263264
local l2 = g2.ghInfo.layer
@@ -275,7 +276,7 @@ function gadgetHandler:Initialize()
275276
end
276277
end)
277278

278-
-- add the gadgets
279+
-- add the gadgets
279280
for _,g in ipairs(unsortedGadgets) do
280281
gadgetHandler:InsertGadget(g)
281282

@@ -298,7 +299,7 @@ function gadgetHandler:LoadGadget(filename)
298299
Spring.Echo('Failed to load: ' .. basename .. ' (' .. err .. ')')
299300
return nil
300301
end
301-
302+
302303
local gadget = gadgetHandler:NewGadget()
303304

304305
setfenv(chunk, gadget)
@@ -1126,6 +1127,18 @@ function gadgetHandler:AllowUnitBuildStep(builderID, builderTeam,
11261127
end
11271128

11281129

1130+
function gadgetHandler:AllowFeatureBuildStep(builderID, builderTeam,
1131+
featureID, featureDefID, part)
1132+
for _,g in ipairs(self.AllowFeatureBuildStepList) do
1133+
if (not g:AllowFeatureBuildStep(builderID, builderTeam,
1134+
featureID, featureDefID, part)) then
1135+
return false
1136+
end
1137+
end
1138+
return true
1139+
end
1140+
1141+
11291142
function gadgetHandler:AllowFeatureCreation(featureDefID, teamID, x, y, z)
11301143
for _,g in ipairs(self.AllowFeatureCreationList) do
11311144
if (not g:AllowFeatureCreation(featureDefID, teamID, x, y, z)) then

0 commit comments

Comments
 (0)