Skip to content

Commit fc3f7d0

Browse files
authored
Merge pull request #1395 from myk002/myk_great_reorg
Script updates for the great reorg
2 parents 566edd7 + f861ec2 commit fc3f7d0

35 files changed

+165
-164
lines changed

assign-preferences.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929
local function format_preference(pref, index)
3030
print(string.format("Preference #%d:", index))
3131

32-
local pref_type = df.unit_preference.T_type[pref.type]
32+
local pref_type = df.unitpref_type[pref.type]
3333
local description = ""
3434
if pref_type == "LikeMaterial" then
3535
description = "Likes material: " .. dfhack.matinfo.getToken(pref.mattype, pref.matindex)
@@ -76,7 +76,7 @@ local preference_functions = {
7676
local ret = {}
7777
if mat_info then
7878
ret = { --luacheck:retype
79-
type = df.unit_preference.T_type.LikeMaterial,
79+
type = df.unitpref_type.LikeMaterial,
8080
item_type = -1,
8181
creature_id = -1,
8282
color_id = -1,
@@ -109,7 +109,7 @@ local preference_functions = {
109109
local index = utils.linear_index(df.global.world.raws.creatures.all, creature_id, "creature_id")
110110
if index then
111111
return {
112-
type = df.unit_preference.T_type.LikeCreature,
112+
type = df.unitpref_type.LikeCreature,
113113
item_type = index,
114114
creature_id = index,
115115
color_id = index,
@@ -186,7 +186,7 @@ local preference_functions = {
186186

187187
if item_type then
188188
return {
189-
type = df.unit_preference.T_type.LikeFood,
189+
type = df.unitpref_type.LikeFood,
190190
item_type = item_type,
191191
creature_id = item_type,
192192
color_id = item_type,
@@ -221,7 +221,7 @@ local preference_functions = {
221221
local index = utils.linear_index(df.global.world.raws.creatures.all, creature_id, "creature_id")
222222
if index then
223223
return {
224-
type = df.unit_preference.T_type.HateCreature,
224+
type = df.unitpref_type.HateCreature,
225225
item_type = index,
226226
creature_id = index,
227227
color_id = index,
@@ -262,7 +262,7 @@ local preference_functions = {
262262
do
263263
if item_type then
264264
return {
265-
type = df.unit_preference.T_type.LikeItem,
265+
type = df.unitpref_type.LikeItem,
266266
item_type = item_type,
267267
creature_id = item_type,
268268
color_id = item_type,
@@ -297,7 +297,7 @@ local preference_functions = {
297297
local index = utils.linear_index(df.global.world.raws.plants.all, plant_id, "id")
298298
if index then
299299
return {
300-
type = df.unit_preference.T_type.LikePlant,
300+
type = df.unitpref_type.LikePlant,
301301
item_type = index,
302302
creature_id = index,
303303
color_id = index,
@@ -330,7 +330,7 @@ local preference_functions = {
330330
local index = utils.linear_index(df.global.world.raws.plants.all, plant_id, "id")
331331
if index then
332332
return {
333-
type = df.unit_preference.T_type.LikeTree,
333+
type = df.unitpref_type.LikeTree,
334334
item_type = index,
335335
creature_id = index,
336336
color_id = index,
@@ -364,7 +364,7 @@ local preference_functions = {
364364
local _, found, index = utils.binsearch(df.global.world.raws.descriptors.colors, color_name, "id")
365365
if found then
366366
return {
367-
type = df.unit_preference.T_type.LikeColor,
367+
type = df.unitpref_type.LikeColor,
368368
item_type = index,
369369
creature_id = index,
370370
color_id = index,
@@ -397,7 +397,7 @@ local preference_functions = {
397397
local index, _ = utils.linear_index(df.global.world.raws.descriptors.shapes, shape_name, "id")
398398
if index then
399399
return {
400-
type = df.unit_preference.T_type.LikeShape,
400+
type = df.unitpref_type.LikeShape,
401401
item_type = index,
402402
creature_id = index,
403403
color_id = index,

autocheese.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function makeCheese(barrel, workshop)
1818
jitem.flags1.milk = true
1919
job.job_items.elements:insert('#', jitem)
2020

21-
if not dfhack.job.attachJobItem(job, barrel, df.job_item_ref.T_role.Reagent, 0, -1) then
21+
if not dfhack.job.attachJobItem(job, barrel, df.job_role_type.Reagent, 0, -1) then
2222
dfhack.error('could not attach item')
2323
end
2424

deep-embark.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ end
137137
function moveEmbarkStuff(selectedBlock, embarkTiles)
138138
local spawnPosCentre
139139
for _, hotkey in ipairs(df.global.plotinfo.main.hotkeys) do
140-
if hotkey.cmd == df.ui_hotkey.T_cmd.Zoom then -- the preset hotkey is centred around the spawn point
140+
if hotkey.cmd == df.hotkey_type.Zoom then -- the preset hotkey is centred around the spawn point
141141
spawnPosCentre = xyz2pos(hotkey.x, hotkey.y, hotkey.z)
142142
hotkey:assign(embarkTiles[math.random(1, #embarkTiles)]) -- set the hotkey to the new spawn point
143143
break

devel/export-dt-ini.lua

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ address('hist_name',df.historical_figure,'name')
201201
address('id',df.historical_figure,'id')
202202
address('hist_fig_info',df.historical_figure,'info')
203203
address('reputation',df.historical_figure_info,'reputation')
204-
address('current_ident',df.historical_figure_info.T_reputation,'cur_identity')
204+
address('current_ident',df.reputation_profilest,'cur_identity')
205205
address('fake_name',df.identity,'name')
206206
address('fake_birth_year',df.identity,'birth_year')
207207
address('fake_birth_time',df.identity,'birth_second')
@@ -356,16 +356,16 @@ address('trans_race_vec',df.creature_interaction_effect_body_transformationst,'r
356356

357357
header('unit_wound_offsets')
358358
address('parts',df.unit_wound,'parts')
359-
address('id',df.unit_wound.T_parts,'body_part_id')
360-
address('layer',df.unit_wound.T_parts,'layer_idx')
359+
address('id',df.unit_wound_layerst,'body_part_id')
360+
address('layer',df.unit_wound_layerst,'layer_idx')
361361
address('general_flags',df.unit_wound,'flags')
362-
address('flags1',df.unit_wound.T_parts,'flags1')
363-
address('flags2',df.unit_wound.T_parts,'flags2')
364-
address('effects_vector',df.unit_wound.T_parts,'effect_type')
365-
address('bleeding',df.unit_wound.T_parts,'bleeding')
366-
address('pain',df.unit_wound.T_parts,'pain')
367-
address('cur_pen',df.unit_wound.T_parts,'cur_penetration_perc')
368-
address('max_pen',df.unit_wound.T_parts,'max_penetration_perc')
362+
address('flags1',df.unit_wound_layerst,'flags1')
363+
address('flags2',df.unit_wound_layerst,'flags2')
364+
address('effects_vector',df.unit_wound_layerst,'effect_type')
365+
address('bleeding',df.unit_wound_layerst,'bleeding')
366+
address('pain',df.unit_wound_layerst,'pain')
367+
address('cur_pen',df.unit_wound_layerst,'cur_penetration_perc')
368+
address('max_pen',df.unit_wound_layerst,'max_penetration_perc')
369369

370370
header('soul_details')
371371
address('name',df.unit_soul,'name')
@@ -377,7 +377,7 @@ address('personality',df.unit_soul,'personality')
377377
address('beliefs',df.unit_personality,'values')
378378
address('emotions',df.unit_personality,'emotions')
379379
address('goals',df.unit_personality,'dreams')
380-
address('goal_realized',df.unit_personality.T_dreams,'flags')
380+
address('goal_realized',df.personality_goalst,'flags')
381381
address('traits',df.unit_personality,'traits')
382382
address('stress_level',df.unit_personality,'stress')
383383
address('needs',df.unit_personality,'needs')
@@ -387,10 +387,10 @@ address('combat_hardened',df.unit_personality,'combat_hardened')
387387
address('likes_outdoors',df.unit_personality,'likes_outdoors')
388388

389389
header('need_offsets')
390-
address('id',df.unit_personality.T_needs,'id')
391-
address('deity_id',df.unit_personality.T_needs,'deity_id')
392-
address('focus_level',df.unit_personality.T_needs,'focus_level')
393-
address('need_level',df.unit_personality.T_needs,'need_level')
390+
address('id',df.personality_needst,'id')
391+
address('deity_id',df.personality_needst,'deity_id')
392+
address('focus_level',df.personality_needst,'focus_level')
393+
address('need_level',df.personality_needst,'need_level')
394394

395395
header('emotion_offsets')
396396
address('emotion_type',df.personality_moodst,'type')
@@ -456,7 +456,7 @@ address('knowledge_category',df.activity_event_ponder_topicst,'topic','research'
456456
address('knowledge_flag',df.activity_event_ponder_topicst,'topic','research','flag_data')
457457
address('perf_type',df.activity_event_performancest,'type')
458458
address('perf_participants',df.activity_event_performancest,'participant_actions')
459-
address('perf_histfig',df.activity_event_performancest.T_participant_actions,'histfig_id')
459+
address('perf_histfig',df.performance_rolest,'histfig_id')
460460

461461
header('art_offsets')
462462
address('name',df.poetic_form,'name')

devel/sc.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ local function check_container(obj, path)
175175
if not (obj._type == df.unit_preference and k == 'item_type')
176176
and not (obj._type == df.unit.T_job and k == 'mood_skill')
177177
and not (obj._type == df.unit and k == 'idle_area_type')
178-
and not (obj._type == df.history_event_body_abusedst.T_props)
179178
and not (field._type == df.skill_rating)
180179
and field.value >= -1 and field.value < 1024 then
181180
local key = tostring(obj._type) .. '.' .. k .. tostring(field.value)

diplomacy.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local p_civ = df.historical_entity.find(df.global.plotinfo.civ_id)
77
-- get list of civs:
88
function get_civ_list()
99
local civ_list = {}
10-
for _, entity in pairs(p_civ.relations.diplomacy) do
10+
for _, entity in ipairs(p_civ.relations.diplomacy.state) do
1111
local cur_civ_id = entity.group_id
1212
local cur_civ = df.historical_entity.find(cur_civ_id)
1313
if cur_civ.type == 0 then
@@ -19,7 +19,7 @@ function get_civ_list()
1919
rel_str = "War"
2020
end
2121
matched = "No"
22-
for _, entity2 in pairs(cur_civ.relations.diplomacy) do
22+
for _, entity2 in ipairs(cur_civ.relations.diplomacy.state) do
2323
if entity2.group_id == p_civ_id and entity2.relation == entity.relation then
2424
matched = "Yes"
2525
end
@@ -51,12 +51,12 @@ end
5151
-- change relation:
5252
function change_relation(civ_id, relation)
5353
print("Changing relation with " .. civ_id .. " to " .. (relation == 0 and "Peace" or "War"))
54-
for _, entity in pairs(p_civ.relations.diplomacy) do
54+
for _, entity in ipairs(p_civ.relations.diplomacy.state) do
5555
local cur_civ_id = entity.group_id
5656
local cur_civ = df.historical_entity.find(cur_civ_id)
5757
if cur_civ.type == 0 and cur_civ_id == civ_id then
5858
entity.relation = relation
59-
for _, entity2 in pairs(cur_civ.relations.diplomacy) do
59+
for _, entity2 in pairs(cur_civ.relations.diplomacy.state) do
6060
if entity2.group_id == p_civ_id then
6161
entity2.relation = relation
6262
end

docs/modtools/pref-edit.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Valid filters:
3434
Include one of these to describe what the id argument represents.
3535
- ``-type <PREFERENCE TYPE>``:
3636
This describes the type of the preference. Can be entered either using the numerical ID or text id.
37-
Run ``lua @df.unit_preference.T_type`` for a full list of valid values.
37+
Run ``lua @df.unitpref_type`` for a full list of valid values.
3838
- ``-subtype <ID>``:
3939
The value for an item's subtype
4040
- ``-material <ID>``:

exportlegends.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ local function export_more_legends_xml()
717717
file:write("\t\t<"..k..">"..escape_xml(dfhack.df2utf(df.creature_raw.find(detailV).name[0])).."</"..k..">\n")
718718
end
719719
elseif df.history_event_body_abusedst:is_instance(event) and (k == "abuse_data") then
720-
if event.abuse_type == df.history_event_body_abusedst.T_abuse_type.Impaled then
720+
if event.abuse_type == df.body_abuse_method_type.Impaled then
721721
file:write("\t\t<item_type>"..tostring(df_enums.item_type[event.abuse_data.Impaled.item_type]):lower().."</item_type>\n")
722722
file:write("\t\t<item_subtype>"..getItemSubTypeName(event.abuse_data.Impaled.item_type,event.abuse_data.Impaled.item_subtype).."</item_subtype>\n")
723723
if (event.abuse_data.Impaled.mat_type > -1) then
@@ -728,25 +728,25 @@ local function export_more_legends_xml()
728728
file:write("\t\t<item_mat>"..dfhack.df2utf(dfhack.matinfo.toString(dfhack.matinfo.decode(event.abuse_data.Impaled.mat_type, event.abuse_data.Impaled.mat_index))).."</item_mat>\n")
729729
end
730730
end
731-
elseif event.abuse_type == df.history_event_body_abusedst.T_abuse_type.Piled then
732-
local val = df.history_event_body_abusedst.T_abuse_data.T_Piled.T_pile_type [event.abuse_data.Piled.pile_type]
731+
elseif event.abuse_type == df.body_abuse_method_type.Piled then
732+
local val = df.body_abuse_sculpture_type [event.abuse_data.Piled.pile_type]
733733
if not val then
734734
file:write("\t\t<pile_type>unknown "..tostring(event.abuse_data.Piled.pile_type).."</pile_type>\n")
735735
else
736736
file:write("\t\t<pile_type>"..tostring(val):lower().."</pile_type>\n")
737737
end
738-
elseif event.abuse_type == df.history_event_body_abusedst.T_abuse_type.Flayed then
738+
elseif event.abuse_type == df.body_abuse_method_type.Flayed then
739739
file:write("\t\t<structure>"..tostring(event.abuse_data.Flayed.structure).."</structure>\n")
740-
elseif event.abuse_type == df.history_event_body_abusedst.T_abuse_type.Hung then
740+
elseif event.abuse_type == df.body_abuse_method_type.Hung then
741741
file:write("\t\t<tree>"..tostring(event.abuse_data.Hung.tree).."</tree>\n")
742742
if (dfhack.matinfo.decode(event.abuse_data.Hung.mat_type, event.abuse_data.Hung.mat_index) == nil) then
743743
file:write("\t\t<mat_type>"..event.abuse_data.Hung.mat_type.."</mat_type>\n")
744744
file:write("\t\t<mat_index>"..event.abuse_data.Hung.mat_index.."</mat_index>\n")
745745
else
746746
file:write("\t\t<item_mat>"..dfhack.df2utf(dfhack.matinfo.toString(dfhack.matinfo.decode(event.abuse_data.Hung.mat_type, event.abuse_data.Hung.mat_index))).."</item_mat>\n")
747747
end
748-
elseif event.abuse_type == df.history_event_body_abusedst.T_abuse_type.Mutilated then -- For completeness. No fields
749-
elseif event.abuse_type == df.history_event_body_abusedst.T_abuse_type.Animated then
748+
elseif event.abuse_type == df.body_abuse_method_type.Mutilated then -- For completeness. No fields
749+
elseif event.abuse_type == df.body_abuse_method_type.Animated then
750750
file:write("\t\t<interaction>"..tostring(event.abuse_data.Animated.interaction).."</interaction>\n")
751751
end
752752
elseif df.history_event_assume_identityst:is_instance(event) and k == "identity" then

fix/civil-war.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
local civ = df.historical_entity.find(df.global.plotinfo.civ_id)
44

55
local fixed = false
6-
for _, entity in pairs(civ.relations.diplomacy) do
6+
for _, entity in ipairs(civ.relations.diplomacy.state) do
77
if entity.group_id == civ.id and entity.relation > 0 then
88
entity.relation = 0
99
fixed = true

gui/advfort.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,8 @@ end
837837
function EnumItems_with_settings( args )
838838
if settings.check_inv then
839839
return EnumItems{pos=args.from_pos,unit=args.unit,
840-
inv={[df.unit_inventory_item.T_mode.Hauled]=settings.use_worn,[df.unit_inventory_item.T_mode.Worn]=settings.use_worn,
841-
[df.unit_inventory_item.T_mode.Weapon]=settings.use_worn,},deep=true}
840+
inv={[df.inv_item_role_type.Hauled]=settings.use_worn,[df.inv_item_role_type.Worn]=settings.use_worn,
841+
[df.inv_item_role_type.Weapon]=settings.use_worn,},deep=true}
842842
else
843843
return EnumItems{pos=args.from_pos}
844844
end
@@ -872,7 +872,7 @@ function find_suitable_items(job,items,job_items)
872872
if not settings.gui_item_select then
873873
if (item_counts[job_id]>0 and item_suitable) or settings.build_by_items then
874874
--cur_item.flags.in_job=true
875-
job.items:insert("#",{new=true,item=cur_item,role=df.job_item_ref.T_role.Reagent,job_item_idx=job_id})
875+
job.items:insert("#",{new=true,item=cur_item,role=df.job_role_type.Reagent,job_item_idx=job_id})
876876
item_counts[job_id]=item_counts[job_id]-cur_item:getTotalDimension()
877877
--print(string.format("item added, job_item_id=%d, item %s, quantity left=%d",job_id,tostring(cur_item),item_counts[job_id]))
878878
used_item_id[cur_item.id]=true
@@ -1021,8 +1021,8 @@ end
10211021
-- print("AAA FAILED!")
10221022
-- return false
10231023
-- end
1024-
-- args.job.items[0].role=df.job_item_ref.T_role.LinkToTarget
1025-
-- args.job.items[1].role=df.job_item_ref.T_role.LinkToTrigger
1024+
-- args.job.items[0].role=df.job_role_type.LinkToTarget
1025+
-- args.job.items[1].role=df.job_role_type.LinkToTrigger
10261026
-- end
10271027
function fake_linking(lever,building,slots)
10281028
local item1=slots[1].items[1]
@@ -1331,8 +1331,8 @@ end
13311331
function usetool:openPutWindow(building)
13321332
local adv=dfhack.world.getAdventurer()
13331333
local items=EnumItems{pos=adv.pos,unit=adv,
1334-
inv={[df.unit_inventory_item.T_mode.Hauled]=true,--[df.unit_inventory_item.T_mode.Worn]=true,
1335-
[df.unit_inventory_item.T_mode.Weapon]=true,},deep=true}
1334+
inv={[df.inv_item_role_type.Hauled]=true,--[df.inv_item_role_type.Worn]=true,
1335+
[df.inv_item_role_type.Weapon]=true,},deep=true}
13361336
local choices={}
13371337
for k,v in pairs(items) do
13381338
table.insert(choices,{text=dfhack.items.getDescription(v,0),item=v})

0 commit comments

Comments
 (0)