Skip to content

Commit 1a477bb

Browse files
Merge branch 'sci-gym-script' into SquidHack
2 parents 9484c09 + 7b77466 commit 1a477bb

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

autotraining.lua

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc)
9494
else
9595
stop()
9696
end
97-
-- start can change the enabled state if the squad cant be found
98-
if state.enabled then
99-
dfhack.print(GLOBAL_KEY .." was persisted with the following data:\nThreshold: ".. state.threshold .. '\n')
100-
end
10197
persist_state()
10298
end
10399

@@ -207,11 +203,7 @@ function addTraining(unit)
207203
for _, squad in ipairs(getTrainingSquads()) do
208204
for i=1,9,1 do
209205
if ( squad.positions[i].occupant == -1 ) then
210-
dfhack.military.addToSquad(unit.id,squad.id,i)
211-
-- squad.positions[i].occupant = unit.hist_figure_id
212-
-- unit.military.squad_id = squad.id
213-
-- unit.military.squad_position = i
214-
return true
206+
return dfhack.military.addToSquad(unit.id,squad.id,i)
215207
end
216208
end
217209
end
@@ -223,11 +215,7 @@ function removeTraining(unit)
223215
for _, squad in ipairs(getTrainingSquads()) do
224216
for i=1,9,1 do
225217
if ( unit.hist_figure_id == squad.positions[i].occupant ) then
226-
dfhack.military.removeFromSquad(unit.id)
227-
-- unit.military.squad_id = -1
228-
-- unit.military.squad_position = -1
229-
-- squad.positions[i].occupant = -1
230-
return true
218+
return dfhack.military.removeFromSquad(unit.id)
231219
end
232220
end
233221
end
@@ -277,7 +265,7 @@ function start()
277265
if (args.t) then
278266
state.threshold = 0-tonumber(args.t)
279267
end
280-
repeatUtil.scheduleEvery(GLOBAL_KEY, 1, 'days', check) -- 997 is the closest prime to 1000
268+
repeatUtil.scheduleEvery(GLOBAL_KEY, 1, 'days', check)
281269
end
282270

283271
function stop()

docs/autotraining.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ autotraining
55
:summary: Assigns citizens to a military squad until they have fulfilled their need for Martial Training
66
:tags: fort auto bugfix units
77

8-
Automation script for citizens to hit the gym when they yearn for the gains. Also passively builds military skills and physical stats.
8+
This script automatically assigns citizens with the need for military training to designated training squads.
99

10-
You need to have at least one squad that is set up for training. This should be a new non-military-use squad. The uniform should be
11-
set to "No Uniform" and the squad should be set to "Constant Training" in the military screen. Edit the squad's schedule to full time training with around 8 units training.
12-
The squad doesn't need months off. The members leave the squad once they have gotten their gains.
10+
You need to have at least one squad that is set up for training. The squad should be set to "Constant Training" in the military screen. The squad doesn't need months off. The members leave the squad once they have satisfied their need for military training.
11+
12+
The configured uniform determines the skills that are acquired by the training dwarves. Providing "No Uniform" is a perfectly valid choice and will make your militarily inclined civilians become wrestlers over time. However, you can also provide weapons and armor to pre-train civilians for future drafts.
1313

1414
Once you have made squads for training use `gui/autotraining` to select the squads and ignored units, as well as the needs threshhold.
1515

@@ -25,10 +25,10 @@ Examples
2525
Current status of script
2626

2727
``enable autotraining``
28-
Checks to see if you have fullfilled the creation of a training gym.
28+
Checks to see if you have fullfilled the creation of a training squad.
2929
If there is no squad marked for training use, a clickable notification will appear letting you know to set one up/
30-
Searches your fort for dwarves with a need to go to the gym, and begins assigning them to said gym.
31-
Once they have fulfilled their need they will be removed from the gym squad to be replaced by the next dwarf in the list.
30+
Searches your fort for dwarves with a need for military training, and begins assigning them to a training squad.
31+
Once they have fulfilled their need they will be removed from their squad to be replaced by the next dwarf in the list.
3232

3333
``disable autotraining``
3434
Stops adding new units to the squad.

internal/control-panel/registry.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ COMMANDS_BY_IDX = {
3535
params={'--time', '14', '--timeUnits', 'days', '--command', '[', 'workorder', 'ShearCreature', ']'}},
3636
{command='autoslab', group='automation', mode='enable'},
3737
{command='autotraining', group='automation', mode='enable',
38-
desc='Automation script for citizens to hit the gym when they yearn for the gains.'},
38+
desc='Automatically assign units with training needs to training squads. '},
3939
{command='ban-cooking all', group='automation', mode='run'},
4040
{command='buildingplan set boulders false', group='automation', mode='run',
4141
desc='Enable if you usually don\'t want to use boulders for construction.'},

0 commit comments

Comments
 (0)