Skip to content

Commit bc3d60f

Browse files
use our precomputed good squads list
1 parent c325bd3 commit bc3d60f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

autotraining.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,16 @@ function checkSquads()
187187
return squads
188188
end
189189

190-
function addTraining(unit)
190+
function addTraining(unit,good_squads)
191191
if (unit.military.squad_id ~= -1) then
192-
for _, squad in ipairs(getTrainingSquads()) do
192+
for _, squad in ipairs(good_squads) do
193193
if unit.military.squad_id == squad.id then
194194
return true
195195
end
196196
end
197197
return false
198198
end
199-
for _, squad in ipairs(getTrainingSquads()) do
199+
for _, squad in ipairs(good_squads) do
200200
for i=1,9,1 do
201201
if ( squad.positions[i].occupant == -1 ) then
202202
return dfhack.military.addToSquad(unit.id,squad.id,i)
@@ -242,11 +242,11 @@ function check()
242242
end
243243
end
244244
for _, unit in ipairs(getTrainingCandidates()) do
245-
local need = getTrainingNeed(unit)
246-
if ( need ~= nil ) then
247-
if ( need.focus_level < state.threshold ) then
248-
local bol = addTraining(unit)
249-
if ( bol ) then
245+
local training_need = getTrainingNeed(unit)
246+
if ( training_need ~= nil ) then
247+
if ( training_need.focus_level < state.threshold ) then
248+
local added = addTraining(unit, squads)
249+
if added then
250250
intraining_count = intraining_count +1
251251
else
252252
inque_count = inque_count +1

0 commit comments

Comments
 (0)