1212local CONFIG = {
1313 MAX_FILL_TILES = 2000 , -- positive integer; safety limit
1414 ALLOW_DIAGONALS = false , -- set true to allow 8-way fill
15- MAX_LIMIT_HARD = 4000 -- hard clamp to avoid runaway fills
15+ MAX_LIMIT_HARD = 4000 , -- hard clamp to avoid runaway fills
1616}
1717
1818---- ---------------------
@@ -167,7 +167,8 @@ local function main(...)
167167 elseif s == ' h' or s == ' help' then
168168 print (' Usage: autoceiling [t] [<max_fill_tiles>]' )
169169 print (' t: enable diagonal flood fill' )
170- print (' <max_fill_tiles>: positive integer, default ' .. CONFIG .MAX_FILL_TILES )
170+ print ((' <max_fill_tiles>: positive integer, default %d, max %d' )
171+ :format (CONFIG .MAX_FILL_TILES , CONFIG .MAX_LIMIT_HARD ))
171172 return
172173 elseif s ~= ' ' then
173174 err (' unknown argument: ' .. tostring (raw ))
@@ -187,9 +188,12 @@ local function main(...)
187188 end
188189 local z_surface = z0 + 1
189190
190- -- Require buildingplan directly; let it error if missing
191- local bp = require (' plugins.buildingplan' )
192- if bp and (not bp .isEnabled or not bp .isEnabled ()) then bp = nil end
191+ local ok , bp = pcall (require , ' plugins.buildingplan' )
192+ if not ok then
193+ bp = nil
194+ elseif bp and (not bp .isEnabled or not bp .isEnabled ()) then
195+ bp = nil
196+ end
193197 local cons = dfhack .constructions
194198
195199 local placed , skipped = 0 , 0
@@ -209,13 +213,13 @@ local function main(...)
209213 elseif has_any_building (x , y , z_surface ) then
210214 skip (' building' )
211215 else
212- local ok , why
216+ local ok_place , why
213217 if bp then
214- ok , why = place_planned (bp , pos )
218+ ok_place , why = place_planned (bp , pos )
215219 else
216- ok , why = place_native (cons , pos )
220+ ok_place , why = place_native (cons , pos )
217221 end
218- if ok then placed = placed + 1 else skip (why or ' unknown' ) end
222+ if ok_place then placed = placed + 1 else skip (why or ' unknown' ) end
219223 end
220224 end
221225
0 commit comments