Skip to content

Commit 6714185

Browse files
committed
finish updating scripts for the Great Reorg
1 parent fc3f7d0 commit 6714185

31 files changed

Lines changed: 123 additions & 92 deletions

add-thought.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function addEmotionToUnit(unit,thought,emotion,severity,strength,subthought)
1414
local properThought = tonumber(thought) or df.unit_thought_type[thought]
1515
local properSubthought = tonumber(subthought)
1616
if not properThought or not df.unit_thought_type[properThought] then
17-
for _,syn in ipairs(df.global.world.raws.syndromes.all) do
17+
for _,syn in ipairs(df.global.world.raws.mat_table.syndromes.all) do
1818
if syn.syn_name == thought then
1919
properThought = df.unit_thought_type.Syndrome
2020
properSubthought = syn.id

assign-preferences.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ local preference_functions = {
8989
mattype = mat_info.type,
9090
matindex = mat_info.index,
9191
mat_state = 0,
92-
active = true,
92+
flags = {visible = true},
9393
prefstring_seed = rng:random()
9494
}
9595
else
@@ -122,7 +122,7 @@ local preference_functions = {
122122
mattype = -1,
123123
matindex = -1,
124124
mat_state = 0,
125-
active = true,
125+
flags = {visible = true},
126126
prefstring_seed = rng:random()
127127
}
128128
else
@@ -199,7 +199,7 @@ local preference_functions = {
199199
mattype = mat_info.type,
200200
matindex = mat_info.index,
201201
mat_state = 1,
202-
active = true,
202+
flags = {visible = true},
203203
prefstring_seed = rng:random()
204204
}
205205
end
@@ -234,7 +234,7 @@ local preference_functions = {
234234
mattype = -1,
235235
matindex = -1,
236236
mat_state = 0,
237-
active = true,
237+
flags = {visible = true},
238238
prefstring_seed = rng:random()
239239
}
240240
else
@@ -275,7 +275,7 @@ local preference_functions = {
275275
mattype = -1,
276276
matindex = -1,
277277
mat_state = 0,
278-
active = true,
278+
flags = {visible = true},
279279
prefstring_seed = rng:random()
280280
}
281281
end
@@ -310,7 +310,7 @@ local preference_functions = {
310310
mattype = -1,
311311
matindex = -1,
312312
mat_state = 0,
313-
active = true,
313+
flags = {visible = true},
314314
prefstring_seed = rng:random()
315315
}
316316
else
@@ -343,7 +343,7 @@ local preference_functions = {
343343
mattype = -1,
344344
matindex = -1,
345345
mat_state = 0,
346-
active = true,
346+
flags = {visible = true},
347347
prefstring_seed = rng:random()
348348
}
349349
else
@@ -377,7 +377,7 @@ local preference_functions = {
377377
mattype = -1,
378378
matindex = -1,
379379
mat_state = 0,
380-
active = true,
380+
flags = {visible = true},
381381
prefstring_seed = rng:random()
382382
}
383383
else
@@ -410,7 +410,7 @@ local preference_functions = {
410410
mattype = -1,
411411
matindex = -1,
412412
mat_state = 0,
413-
active = true,
413+
flags = {visible = true},
414414
prefstring_seed = rng:random()
415415
}
416416
else

devel/export-dt-ini.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ address('musical_forms_vector',globals,'world','musical_forms','all')
9292
address('dance_forms_vector',globals,'world','dance_forms','all')
9393
address('occupations_vector',globals,'world','occupations','all')
9494
address('world_data',globals,'world','world_data')
95-
address('material_templates_vector',globals,'world','raws','material_templates')
95+
address('material_templates_vector',globals,'world','raws','material_templates','all')
9696
address('inorganics_vector',globals,'world','raws','inorganics')
9797
address('plants_vector',globals,'world','raws','plants','all')
9898
address('races_vector',globals,'world','raws','creatures','all')
@@ -255,14 +255,14 @@ address('pants_armor_properties',df.itemdef_pantsst,'props')
255255
address('other_armor_properties',df.itemdef_helmst,'props')
256256

257257
header('material_offsets')
258-
address('solid_name',df.material_common,'state_name','Solid')
259-
address('liquid_name',df.material_common,'state_name','Liquid')
260-
address('gas_name',df.material_common,'state_name','Gas')
261-
address('powder_name',df.material_common,'state_name','Powder')
262-
address('paste_name',df.material_common,'state_name','Paste')
263-
address('pressed_name',df.material_common,'state_name','Pressed')
264-
address('flags',df.material_common,'flags')
265-
address('reaction_class',df.material_common,'reaction_class')
258+
address('solid_name',df.material,'state_name','Solid')
259+
address('liquid_name',df.material,'state_name','Liquid')
260+
address('gas_name',df.material,'state_name','Gas')
261+
address('powder_name',df.material,'state_name','Powder')
262+
address('paste_name',df.material,'state_name','Paste')
263+
address('pressed_name',df.material,'state_name','Pressed')
264+
address('flags',df.material,'flags')
265+
address('reaction_class',df.material,'reaction_class')
266266
address('prefix',df.material,'prefix')
267267
address('inorganic_materials_vector',df.inorganic_raw,'material')
268268
address('inorganic_flags',df.inorganic_raw,'flags')
@@ -320,7 +320,7 @@ address('size_info',df.unit,'body','size_info','size_cur')
320320
address('size_base',df.unit,'body','size_info','size_base')
321321
address('curse',df.unit,'curse','name')
322322
address('curse_add_flags1',df.unit,'curse','add_tags1')
323-
address('turn_count',df.unit,'curse','time_on_site')
323+
address('turn_count',df.unit,'curse','interaction','time_on_site')
324324
address('souls',df.unit,'status','souls')
325325
address('states',df.unit,'status','misc_traits')
326326
address('labors',df.unit,'status','labors')

devel/export-map.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ local function setup_keys(options)
158158
KEYS.MATERIAL.STONE = {}
159159
KEYS.MATERIAL.GEM = {}
160160

161-
for id, rock in ipairs(df.global.world.raws.inorganics) do
161+
for id, rock in ipairs(df.global.world.raws.inorganics.all) do
162162
local material = rock.material
163163
local name = material.state_adj.Solid
164164
KEYS.MATERIAL.SOLID[id] = name

devel/tree-info.lua

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,57 @@
11
--Print a tree_info visualization of the tree at the cursor.
22
--@module = true
33

4-
local branch_dir =
5-
{
6-
[0] = ' ',
7-
[1] = string.char(26), --W
8-
[2] = string.char(25), --N
9-
[3] = string.char(217), --WN
10-
[4] = string.char(27), --E
11-
[5] = string.char(196), --WE
12-
[6] = string.char(192), --NE
13-
[7] = string.char(193), --WNE
14-
[8] = string.char(24), --S
15-
[9] = string.char(191), --WS
16-
[10] = string.char(179), --NS
17-
[11] = string.char(180), --WNS
18-
[12] = string.char(218), --ES
19-
[13] = string.char(194), --WES
20-
[14] = string.char(195), --NES
21-
[15] = string.char(197), --WNES
4+
-- [w][n][e][s]
5+
local branch_chars = {
6+
[true]={
7+
[true]={
8+
[true]={
9+
[true]=string.char(197), --WNES
10+
[false]=string.char(193), --WNE
11+
},
12+
[false]={
13+
[true]=string.char(180), --WNS
14+
[false]=string.char(217), --WN
15+
},
16+
},
17+
[false]={
18+
[true]={
19+
[true]=string.char(194), --WES
20+
[false]=string.char(196), --WE
21+
},
22+
[false]={
23+
[true]=string.char(191), --WS
24+
[false]=string.char(26), --W
25+
},
26+
},
27+
},
28+
[false]={
29+
[true]={
30+
[true]={
31+
[true]=string.char(195), --NES
32+
[false]=string.char(192), --NE
33+
},
34+
[false]={
35+
[true]=string.char(179), --NS
36+
[false]=string.char(25), --N
37+
},
38+
},
39+
[false]={
40+
[true]={
41+
[true]=string.char(218), --ES
42+
[false]=string.char(27), --E
43+
},
44+
[false]={
45+
[true]=string.char(24), --S
46+
[false]=' ',
47+
},
48+
},
49+
},
2250
}
2351

2452
local function print_color(s, color)
2553
dfhack.color(color)
26-
dfhack.print(s)
54+
dfhack.print(dfhack.df2console(s))
2755
dfhack.color(COLOR_RESET)
2856
end
2957

@@ -68,7 +96,7 @@ function printTreeTile(bits)
6896
end
6997

7098
chars = chars-2
71-
print_color(' '..(branch_dir[bits.branches_dir] or '?'), COLOR_GREY)
99+
print_color(' '..(branch_chars[bits.branch_w][bits.branch_n][bits.branch_e][bits.branch_s] or '?'), COLOR_GREY)
72100

73101
local dir = bits.parent_dir
74102
if dir > 0 then

docs/fix/population-cap.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fix/population-cap
55
:summary: Ensure the population cap is respected.
66
:tags: fort bugfix
77

8-
Run this if you continue to get migrant wave even after you have exceeded your
8+
Run this if you continue to get migrant waves even after you have exceeded your
99
set population cap.
1010

1111
The reason this tool is needed is that the game only updates the records of your

dwarf-op.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ local seasons = {
733733
'winter',
734734
}
735735
function GetWave(dwf)
736-
arrival_time = current_tick - dwf.curse.time_on_site;
736+
arrival_time = current_tick - dwf.curse.interaction.time_on_site;
737737
--print(string.format("Current year %s, arrival_time = %s, ticks_per_year = %s", df.global.cur_year, arrival_time, ticks_per_year))
738738
arrival_year = df.global.cur_year + (arrival_time // ticks_per_year);
739739
arrival_season = 1 + (arrival_time % ticks_per_year) // ticks_per_season;

exportlegends.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -784,16 +784,16 @@ local function export_more_legends_xml()
784784
file:write("\t\t<caste>"..(world.raws.creatures.all[event.race].caste[v].caste_id):lower().."</caste>\n")
785785
end
786786
elseif k == "interaction" and df.history_event_hf_does_interactionst:is_instance(event) then
787-
if #world.raws.interactions[v].sources > 0 then
788-
local str_1 = world.raws.interactions[v].sources[0].hist_string_1
787+
if #world.raws.interactions.all[v].sources > 0 then
788+
local str_1 = world.raws.interactions.all[v].sources[0].hist_string_1
789789
if string.sub (str_1, 1, 1) == " " and string.sub (str_1, string.len (str_1), string.len (str_1)) == " " then
790790
str_1 = string.sub (str_1, 2, string.len (str_1) - 1)
791791
end
792-
file:write("\t\t<interaction_action>"..str_1..world.raws.interactions[v].sources[0].hist_string_2.."</interaction_action>\n")
792+
file:write("\t\t<interaction_action>"..str_1..world.raws.interactions.all[v].sources[0].hist_string_2.."</interaction_action>\n")
793793
end
794794
elseif k == "interaction" and df.history_event_hf_learns_secretst:is_instance(event) then
795-
if #world.raws.interactions[v].sources > 0 then
796-
file:write("\t\t<secret_text>"..world.raws.interactions[v].sources[0].name.."</secret_text>\n")
795+
if #world.raws.interactions.all[v].sources > 0 then
796+
file:write("\t\t<secret_text>"..world.raws.interactions.all[v].sources[0].name.."</secret_text>\n")
797797
end
798798
elseif df.history_event_hist_figure_diedst:is_instance(event) and k == "weapon" then
799799
for detailK,detailV in pairs(v) do

fix/population-cap.lua

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1-
local ui = df.global.plotinfo
2-
local ui_stats = ui.tasks
3-
local civ = df.historical_entity.find(ui.civ_id)
1+
local plotinfo = df.global.plotinfo
2+
local tasks = plotinfo.tasks
3+
local knowledge = tasks.knowledge
44

5-
if not civ then
5+
local civ = df.historical_entity.find(plotinfo.civ_id)
6+
7+
if not dfhack.isMapLoaded() or not dfhack.world.isFortressMode() or not civ then
68
qerror('No active fortress.')
79
end
810

911
local civ_stats = civ.activity_stats
1012

11-
if not civ_stats then
12-
civ.activity_stats = {
13-
new = true,
14-
created_weapons = { resize = #ui_stats.created_weapons },
15-
discovered_creature_foods = { resize = #ui_stats.discovered_creature_foods },
16-
discovered_creatures = { resize = #ui_stats.discovered_creatures },
17-
discovered_plant_foods = { resize = #ui_stats.discovered_plant_foods },
18-
discovered_plants = { resize = #ui_stats.discovered_plants },
19-
}
20-
civ_stats = civ.activity_stats
13+
local function upsize(civ_vec, tasks_vec)
14+
local tasks_vec_size = #tasks_vec
15+
if #civ_vec < tasks_vec_size then
16+
civ_vec:resize(tasks_vec_size)
17+
end
2118
end
2219

20+
upsize(civ_stats.created_weapons, tasks.created_weapons)
21+
upsize(civ_stats.knowledge.discovered_creature_foods, knowledge.discovered_creature_foods)
22+
upsize(civ_stats.knowledge.discovered_creatures, knowledge.discovered_creatures)
23+
upsize(civ_stats.knowledge.discovered_plant_foods, knowledge.discovered_plant_foods)
24+
upsize(civ_stats.knowledge.discovered_plants, knowledge.discovered_plants)
25+
2326
-- Use max to keep at least some of the original caravan communication idea
24-
local new_pop = math.max(civ_stats.population, ui_stats.population)
27+
local new_pop = math.max(civ_stats.population, tasks.population)
2528

2629
if civ_stats.population ~= new_pop then
2730
civ_stats.population = new_pop

fix/wildlife.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ end
4646

4747
local function refund_population(entry)
4848
local epop = entry.pop
49-
for _,population in ipairs(df.global.world.populations) do
49+
for _,population in ipairs(df.global.world.populations.all) do
5050
local wpop = population.population
5151
if population.quantity < 10000001 and
5252
wpop.region_x == epop.region_x and

0 commit comments

Comments
 (0)