-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstockpile.lua
1789 lines (1521 loc) · 52.4 KB
/
stockpile.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function count_enabled(list, subset)
local ret = 0
if subset then --as:subset=number[]
for i,v in ipairs(subset) do
if --[[v < #list and]] istrue(list[v]) then
ret = ret + 1
end
end
else
for i,v in ipairs(list) do
if istrue(v) then
ret = ret + 1
end
end
end
return ret
end
function populate_enabled(list, cnt)
if list._type ~= 'bool[]' then
list:resize(cnt)
for i=0,cnt-1 do
list[i] = 1
end
else
for i=0,cnt-1 do
list[i] = true
end
end
end
local item_quality = {
'Standard',
'Well-Crafted',
'Finely-Crafted',
'Superior Quality',
'Exceptional',
'Masterwork',
'Artifact'
}
local function quality_titles()
return item_quality
end
local furniture_other_materials = {
'Wood',
'Plant Cloth',
'Bone',
'Tooth',
'Horn',
'Pearl',
'Shell',
'Leather',
'Silk',
'Amber',
'Coral',
'Green Glass',
'Clear Glass',
'Crystal Glass',
'Yarn'
}
local function furniture_other_material_titles()
return furniture_other_materials
end
local ammo_other_materials = {
'Wood',
'Bone',
}
local function ammo_other_material_titles()
return ammo_other_materials
end
local goods_other_materials = {
'Wood',
'Plant Cloth',
'Bone',
'Tooth',
'Horn',
'Pearl',
'Shell',
'Leather',
'Silk',
'Amber',
'Coral',
'Green Glass',
'Clear Glass',
'Crystal Glass',
'Yarn',
'Wax'
}
local function goods_other_material_titles()
return goods_other_materials
end
local weapons_other_materials = {
'Wood',
'Plant Cloth',
'Bone',
'Shell',
'Leather',
'Silk',
'Green Glass',
'Clear Glass',
'Crystal Glass',
'Yarn',
}
local function weapons_other_material_titles()
return weapons_other_materials
end
local glasses = {
'Green Glass',
'Clear Glass',
'Crystal Glass'
}
local function glass_titles()
return glasses
end
local bars_other_materials = { 'Coal', 'Potash', 'Ash', 'Pearlash', 'Soap' }
local blocks_other_materials = { 'Green Glass', 'Clear Glass', 'Crystal Glass', 'Wood' }
local function bars_other_material_titles()
return bars_other_materials
end
local function blocks_other_material_titles()
return blocks_other_materials
end
local furniture_type = {
'FLOODGATE',
'HATCH_COVER',
'GRATE',
'DOOR',
'CATAPULTPARTS',
'BALLISTAPARTS',
'TRAPPARTS',
'BED',
'TRACTION_BENCH',
'WINDOW',
'CHAIR',
'TABLE',
'COFFIN',
'STATUE',
'SLAB',
'QUERN',
'MILLSTONE',
'ARMORSTAND',
'WEAPONRACK',
'CABINET',
'ANVIL',
'BUCKET',
'BIN',
'BOX',
'SIEGEAMMO',
'BARREL',
'BALLISTAARROWHEAD',
'PIPE_SECTION',
--tool types
'FOOD_STORAGE',
'MINECART',
'WHEELBARROW',
'OTHER_LARGE_TOOLS',
'SAND_BAG',
}
local function furniture_type_titles()
return {
'Floodgates',
'Hatch Covers',
'Grates',
'Doors',
'Catapult Parts',
'Ballista Parts',
'Mechanisms',
'Beds',
'Traction Benches',
'Windows',
'Thrones',
'Tables',
'Coffins',
'Statues',
'Slabs',
'Querns',
'Millstones',
'Armor Stands',
'Weapon Racks',
'Cabinets',
'Anvils',
'Buckets',
'Bins',
'Boxes and Bags',
'Siege Ammo',
'Barrels',
'Ballista Arrow Heads',
'Pipe Sections',
--tool types
--todo: are these hardcoded ???
'Large Pots / Food Storage',
'Minecarts',
'Wheelbarrows',
'Other Large Tools',
'Sand Bags',
}
end
local function gem_to_mat_idx(pos)
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.material.flags.IS_GEM then
table.insert(ret, i)
if pos and #ret == pos then
return i
end
end
end
return ret
end
--todo: game uses plural when in Gems group and singular when in Finished Goods group
local function gem_titles()
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.material.flags.IS_GEM then
local t = capitalize(v.material.state_name[0])
table.insert(ret, t)
end
end
return ret
end
local function stoneclay_to_mat_idx(pos)
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.material.flags.IS_STONE then
table.insert(ret, i)
if pos and #ret == pos then
return i
end
end
end
return ret
end
local function stoneclay_titles()
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.material.flags.IS_STONE then
local t = capitalize(v.material.state_name[0])
table.insert(ret, t)
end
end
return ret
end
local function metal_to_mat_idx(pos)
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.material.flags.IS_METAL then
table.insert(ret, i)
if pos and #ret == pos then
return i
end
end
end
return ret
end
local function metal_titles()
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.material.flags.IS_METAL then
local t = capitalize(v.material.state_name[0])
table.insert(ret, t)
end
end
return ret
end
local function metalore_to_mat_idx(pos)
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.flags.METAL_ORE then
table.insert(ret, i)
if pos and #ret == pos then
return i
end
end
end
return ret
end
local function metalore_titles()
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.flags.METAL_ORE then
local t = capitalize(v.material.state_name[0])
table.insert(ret, t)
end
end
return ret
end
local function economic_to_mat_idx(pos)
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.material.flags.IS_STONE and not v.flags.METAL_ORE and #v.economic_uses>0 then
table.insert(ret, i)
if pos and #ret == pos then
return i
end
end
end
return ret
end
local function economic_titles()
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.material.flags.IS_STONE and not v.flags.METAL_ORE and #v.economic_uses>0 then
local t = capitalize(v.material.state_name[0])
table.insert(ret, t)
end
end
return ret
end
local function otherstone_to_mat_idx(pos)
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.material.flags.IS_STONE and not v.material.flags.NO_STONE_STOCKPILE and not v.flags.METAL_ORE and #v.economic_uses==0 then
table.insert(ret, i)
if pos and #ret == pos then
return i
end
end
end
return ret
end
local function otherstone_titles()
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.material.flags.IS_STONE and not v.material.flags.NO_STONE_STOCKPILE and not v.flags.METAL_ORE and #v.economic_uses==0 then
local t = capitalize(v.material.state_name[0])
table.insert(ret, t)
end
end
return ret
end
--todo: is this the right way?
local function clay_to_mat_idx(pos)
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.flags.SOIL and #v.material.reaction_product.id>0 and v.material.reaction_product.id[0].value=='FIRED_MAT' then
table.insert(ret, i)
if pos and #ret == pos then
return i
end
end
end
return ret
end
--todo: is this the right way?
local function clay_titles()
local ret = {}
for i,v in ipairs(df.global.world.raws.inorganics) do
if v.flags.SOIL and #v.material.reaction_product.id>0 and v.material.reaction_product.id[0].value=='FIRED_MAT' then
local t = capitalize(v.material.state_name[0])
table.insert(ret, t)
end
end
return ret
end
local function animal_to_creature_idx(pos)
local ret = {}
for i,v in ipairs(df.global.world.raws.creatures.all) do
--todo: is this correct?
if not v.flags.HAS_ANY_FEATURE_BEAST and not v.flags.HAS_ANY_NIGHT_CREATURE and not v.flags.HAS_ANY_DEMON and not v.flags.HAS_ANY_TITAN and not v.flags.EQUIPMENT_WAGON then
table.insert(ret, i)
if pos and #ret == pos then
return i
end
end
end
return ret
end
--todo: game uses plural when in Animals group and singular when in Refuse group
local function animal_titles()
local ret = {}
for i,v in ipairs(df.global.world.raws.creatures.all) do
--todo: is this correct?
if not v.flags.HAS_ANY_FEATURE_BEAST and not v.flags.HAS_ANY_NIGHT_CREATURE and not v.flags.HAS_ANY_DEMON and not v.flags.HAS_ANY_TITAN and not v.flags.EQUIPMENT_WAGON then
local t = capitalize(v.name[0])
table.insert(ret, t)
end
end
return ret
end
--todo: use mat_table.organic_types.Plants
function foodplant_to_plant_idx(pos)
local ret = {}
for i,v in ipairs(df.global.world.raws.plants.all) do
local flags = v.flags
if flags.SPRING or flags.SUMMER or flags.AUTUMN or flags.WINTER then
table.insert(ret, i)
if pos and #ret == pos then
return i
end
end
end
return ret
end
function foodplant_titles()
local ret = {}
for i,v in ipairs(df.global.world.raws.plants.all) do
local flags = v.flags
if flags.SPRING or flags.SUMMER or flags.AUTUMN or flags.WINTER then
local t = capitalize(v.name)
table.insert(ret, t)
end
end
return ret
end
function tree_to_plant_idx(pos)
local ret = {}
for i,v in ipairs(df.global.world.raws.plants.all) do
if v.flags.TREE then
table.insert(ret, i)
if pos and #ret == pos then
return i
end
end
end
return ret
end
function tree_titles()
local ret = {}
for i,v in ipairs(df.global.world.raws.plants.all) do
if v.flags.TREE then
local t = capitalize(v.name_plural)
table.insert(ret, t)
end
end
return ret
end
function glass_to_builtin_idx(pos)
local idxs = { 3, 4, 5 }
if pos then
return idxs[pos]
end
return idxs
end
local refuse_types = {
df.item_type.REMAINS,
df.item_type.MEAT,
df.item_type.FISH,
df.item_type.FISH_RAW,
df.item_type.SEEDS,
df.item_type.PLANT,
df.item_type.PLANT_GROWTH, --?
df.item_type.CHEESE,
df.item_type.FOOD,
df.item_type.EGG,
df.item_type.WOOD,
df.item_type.DOOR,
df.item_type.FLOODGATE,
df.item_type.BED,
df.item_type.CHAIR,
df.item_type.CHAIN,
df.item_type.FLASK,
df.item_type.GOBLET,
df.item_type.INSTRUMENT,
df.item_type.TOY,
df.item_type.WINDOW,
df.item_type.CAGE,
df.item_type.BARREL,
df.item_type.BUCKET,
df.item_type.ANIMALTRAP,
df.item_type.TABLE,
df.item_type.COFFIN,
df.item_type.STATUE,
df.item_type.WEAPON,
df.item_type.ARMOR,
df.item_type.SHOES,
df.item_type.SHIELD,
df.item_type.HELM,
df.item_type.GLOVES,
df.item_type.BOX,
df.item_type.BIN,
df.item_type.ARMORSTAND,
df.item_type.WEAPONRACK,
df.item_type.CABINET,
df.item_type.FIGURINE,
df.item_type.AMULET,
df.item_type.SCEPTER,
df.item_type.AMMO,
df.item_type.CROWN,
df.item_type.RING,
df.item_type.EARRING,
df.item_type.BRACELET,
df.item_type.GEM,
df.item_type.ANVIL,
df.item_type.VERMIN,
df.item_type.PET,
df.item_type.SKIN_TANNED,
df.item_type.THREAD,
df.item_type.CLOTH,
df.item_type.TOTEM,
df.item_type.PANTS,
df.item_type.BACKPACK,
df.item_type.QUIVER,
df.item_type.CATAPULTPARTS,
df.item_type.BALLISTAPARTS,
df.item_type.SIEGEAMMO,
df.item_type.BALLISTAARROWHEAD,
df.item_type.TRAPPARTS,
df.item_type.TRAPCOMP,
df.item_type.DRINK,
df.item_type.POWDER_MISC,
df.item_type.LIQUID_MISC,
df.item_type.COIN,
df.item_type.GLOB,
df.item_type.PIPE_SECTION,
df.item_type.HATCH_COVER,
df.item_type.GRATE,
df.item_type.QUERN,
df.item_type.MILLSTONE,
df.item_type.SPLINT,
df.item_type.CRUTCH,
df.item_type.TRACTION_BENCH,
df.item_type.TOOL,
df.item_type.SLAB,
df.item_type.BOOK
}
function refusetype_to_itemtype_idx(pos)
if pos then
return refuse_types[pos]
end
return refuse_types
end
local function refuse_type_titles()
return {
'Remains',
'Meat',
'Fish',
'Raw Fish',
'Seeds',
'Plants',
'Leaves',
'Cheese',
'Prepared Meals',
'Eggs',
'Logs',
'Doors',
'Floodgates',
'Beds',
'Thrones',
'Chains',
'Flasks',
'Goblets',
'Musical Instruments',
'Toys',
'Windows',
'Cages',
'Barrels',
'Buckets',
'Animal Traps',
'Tables',
'Coffins',
'Statues',
'Weapons',
'Armor',
'Footwear',
'Shields / Bucklers',
'Headwear',
'Handwear',
'Boxes and Bags',
'Bins',
'Armor Stands',
'Weapon Racks',
'Cabinets',
'Figurines',
'Amulets',
'Scepters',
'Ammunition',
'Crowns',
'Rings',
'Earrings',
'Bracelets',
'Large Gems',
'Anvils',
'Small Live Animals',
'Small Tame Animals',
'Tanned Hides',
'Thread',
'Cloth',
'Totems',
'Legwear',
'Backpacks',
'Quivers',
'Catapult Parts',
'Ballista Parts',
'Siege Ammo',
'Ballista Arrow Heads',
'Mechanisms',
'Trap Components',
'Drinks',
'Powder',
'Liquid',
'Coins',
'Glob',
'Pipe Sections',
'Hatch Covers',
'Grates',
'Querns',
'Millstones',
'Splints',
'Crutches',
'Traction Benches',
'Tools',
'Slabs',
'Books',
}
end
local goods_types = {
df.item_type.CHAIN,
df.item_type.FLASK,
df.item_type.GOBLET,
df.item_type.INSTRUMENT,
df.item_type.TOY,
df.item_type.ARMOR,
df.item_type.SHOES,
df.item_type.HELM,
df.item_type.GLOVES,
df.item_type.FIGURINE,
df.item_type.AMULET,
df.item_type.SCEPTER,
df.item_type.CROWN,
df.item_type.RING,
df.item_type.EARRING,
df.item_type.BRACELET,
df.item_type.GEM,
df.item_type.TOTEM,
df.item_type.PANTS,
df.item_type.BACKPACK,
df.item_type.QUIVER,
df.item_type.SPLINT,
df.item_type.CRUTCH,
df.item_type.TOOL,
df.item_type.BOOK
}
function goods_to_itemtype_idx(pos)
if pos then
return goods_types[pos]
end
return goods_types
end
function goods_titles()
return {
'Chains',
'Flasks',
'Goblets',
'Musical Instruments',
'Toys',
'Armor',
'Footwear',
'Headwear',
'Handwear',
'Figurines',
'Amulets',
'Scepters',
'Crowns',
'Rings',
'Earrings',
'Bracelets',
'Large Gems',
'Totems',
'Legwear',
'Backpacks',
'Quivers',
'Splints',
'Crutches',
'Tools',
'Books'
}
end
local function itemdef_titles(defs)
local ret = {}
for i,v in ipairs(defs) do
local t = capitalize((#v.adjective>0 and (v.adjective .. ' ') or '') .. v.name_plural)
table.insert(ret, t)
end
return ret
end
function ammo_type_titles()
return itemdef_titles(df.global.world.raws.itemdefs.ammo)
end
function weapon_titles()
return itemdef_titles(df.global.world.raws.itemdefs.weapons)
end
function trapcomp_titles()
return itemdef_titles(df.global.world.raws.itemdefs.trapcomps)
end
function armor_titles()
return itemdef_titles(df.global.world.raws.itemdefs.armor)
end
function headwear_titles()
return itemdef_titles(df.global.world.raws.itemdefs.helms)
end
function footwear_titles()
return itemdef_titles(df.global.world.raws.itemdefs.shoes)
end
function handwear_titles()
return itemdef_titles(df.global.world.raws.itemdefs.gloves)
end
function legwear_titles()
return itemdef_titles(df.global.world.raws.itemdefs.pants)
end
function shield_titles()
return itemdef_titles(df.global.world.raws.itemdefs.shields)
end
--luacheck: in=number,number,string
function organic_titles_prefixstate(group, state, suffix)
local types = df.global.world.raws.mat_table.organic_types[group]
local indexes = df.global.world.raws.mat_table.organic_indexes[group]
local ret = {}
for i=0,#types-1 do
local mi = dfhack.matinfo.decode(types[i], indexes[i])
if mi and mi.material then
local mat = mi.material
local t = capitalize((#mat.prefix>0 and (mat.prefix .. ' ') or '') .. mat.state_name[state] .. suffix)
table.insert(ret, t)
else
table.insert(ret, '#unknown#')
end
end
return ret
end
function organic_leather_titles()
return organic_titles_prefixstate('Leather', 0, '')
end
function organic_meat_titles()
local types = df.global.world.raws.mat_table.organic_types.Meat
local indexes = df.global.world.raws.mat_table.organic_indexes.Meat
--xxx: we skip first two mats in the list because they seem to be placeholders for these two hardcoded options
local ret = { 'Meat', 'Prepared Eye' }
for i=2,#types-1 do
local mi = dfhack.matinfo.decode(types[i], indexes[i])
if mi and mi.material then
local mat = mi.material
local t = capitalize((#mat.meat_name[2]>0 and (mat.meat_name[2] .. ' ') or '') .. (#mat.prefix>0 and (mat.prefix .. ' ') or '') .. mat.meat_name[0])
table.insert(ret, t)
else
table.insert(ret, '#unknown#')
end
end
return ret
end
function organic_fish_titles()
local types = df.global.world.raws.mat_table.organic_types.Fish
local indexes = df.global.world.raws.mat_table.organic_indexes.Fish
local ret = {}
for i=0,#types-1 do
local raw = df.global.world.raws.creatures.all[types[i]]
if raw then
local caste = raw.caste[indexes[i]]
local t = capitalize(caste.caste_name[0])
if caste.sex == df.pronoun_type.she then
t = t .. ', ' .. SYMBOL_FEMALE_DF
elseif caste.sex == df.pronoun_type.he then
t = t .. ', ' .. SYMBOL_MALE_DF
end
table.insert(ret, t)
end
end
return ret
end
function organic_rawfish_titles()
local types = df.global.world.raws.mat_table.organic_types.UnpreparedFish
local indexes = df.global.world.raws.mat_table.organic_indexes.UnpreparedFish
local ret = {}
for i=0,#types-1 do
local raw = df.global.world.raws.creatures.all[types[i]]
if raw then
local caste = raw.caste[indexes[i]]
local t = 'Unprepared Raw ' .. capitalize(caste.caste_name[0])
if caste.sex == df.pronoun_type.she then
t = t .. ', ' .. SYMBOL_FEMALE_DF
elseif caste.sex == df.pronoun_type.he then
t = t .. ', ' .. SYMBOL_MALE_DF
end
table.insert(ret, t)
end
end
return ret
end
function organic_egg_titles()
local types = df.global.world.raws.mat_table.organic_types.Eggs
local indexes = df.global.world.raws.mat_table.organic_indexes.Eggs
local ret = {}
for i=0,#types-1 do
local raw = df.global.world.raws.creatures.all[types[i]]
if raw then
local caste = raw.caste[indexes[i]]
local t = capitalize(caste.caste_name[0] .. ' egg')
table.insert(ret, t)
end
end
return ret
end
function organic_silk_thread_titles()
return organic_titles_prefixstate('Silk', 0, ' thread')
end
function organic_silk_cloth_titles()
return organic_titles_prefixstate('Silk', 0, ' cloth')
end
function organic_plantfiber_thread_titles()
return organic_titles_prefixstate('PlantFiber', 0, ' thread')
end
function organic_plantfiber_cloth_titles()
return organic_titles_prefixstate('PlantFiber', 0, ' cloth')
end
function organic_yarn_thread_titles()
return organic_titles_prefixstate('Yarn', 0, ' thread')
end
function organic_yarn_cloth_titles()
return organic_titles_prefixstate('Yarn', 0, ' cloth')
end
function organic_metalthread_thread_titles()
return organic_titles_prefixstate('MetalThread', 0, ' strands')
end
function organic_metalthread_cloth_titles()
return organic_titles_prefixstate('MetalThread', 0, ' cloth')
end
function organic_plantdrink_titles()
return organic_titles_prefixstate('PlantDrink', 'Liquid', '')
end
function organic_creaturedrink_titles()
return organic_titles_prefixstate('CreatureDrink', 'Liquid', '')
end
function organic_plantcheese_titles()
return organic_titles_prefixstate('PlantCheese', 0, '')
end
function organic_creaturecheese_titles()
return organic_titles_prefixstate('CreatureCheese', 0, '')
end
function organic_seed_titles()
local types = df.global.world.raws.mat_table.organic_types.Seed
local indexes = df.global.world.raws.mat_table.organic_indexes.Seed
local ret = {}
for i=0,#types-1 do
local mi = dfhack.matinfo.decode(types[i], indexes[i])
if mi and mi.plant then
local t = capitalize(mi.plant.seed_plural)
table.insert(ret, t)
else
table.insert(ret, '#unknown#')
end
end
return ret
end
function organic_leaf_titles()
local types = df.global.world.raws.mat_table.organic_types.Leaf
local indexes = df.global.world.raws.mat_table.organic_indexes.Leaf
local ret = {}
for i=0,#types-1 do
local mi = dfhack.matinfo.decode(types[i], indexes[i])
if mi and mi.plant then
local t = nil
for j,growth in ipairs(mi.plant.growths) do
if growth.str_growth_item[3] == mi.material.id then
t = growth.name
break
end
end
t = t or ((#mat.prefix>0 and (mat.prefix .. ' ') or '') .. mat.state_name[state] .. suffix)
t = capitalize(t)
table.insert(ret, t)
else
table.insert(ret, '#unknown#')
end
end
return ret
end
function organic_plantpowder_titles()
return organic_titles_prefixstate('PlantPowder', 'Powder', '')
end
function organic_creaturepowder_titles()
return organic_titles_prefixstate('CreaturePowder', 'Powder', '')
end
function organic_glob_titles()
return organic_titles_prefixstate('Glob', 0, '')
end
function organic_paste_titles()
return organic_titles_prefixstate('Paste', 'Paste', '')
end
function organic_pressed_titles()