-
Notifications
You must be signed in to change notification settings - Fork 0
/
stocksarmor.lua
129 lines (110 loc) · 3.1 KB
/
stocksarmor.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
-- the script for accessing stored clothing
local args = {...}
local utils = require('utils');
require('hack/scripts/stocksfuncs')
dofile('hack/scripts/stocksfuncs.lua');
-----------------------------
--functions
----------------------------
function find_armor()
local b = dfhack.script_environment('stocksfuncs').get_all_items()
armor = {}
for i, item in ipairs(b) do
if item.isArmorNotClothing(item) == true then
table.insert(armor, item)
--print(item.subtype.name)
end
end
count_armor_types(armor)
end
function count_armor_types(armor)
armortypes = {}
--subtypes = {}
for i, item in ipairs(armor) do
typestored = false
--print(item.subtype.name)
for j, k in ipairs(armortypes) do
--subtypestored = false
if item.subtype.name == k then --item._type
typestored = true
end
end
if typestored == false then
table.insert(armortypes, item.subtype.name) --item._type
end
end
-- maint = {}
-- for i, item in ipairs(armor) do
--print(item._type)
-- z = dfhack.script_environment('stocksfuncs').get_type(item)
-- print(z)
-- main = false
-- for j, k in ipairs(maint) do
-- if z == k then
-- main = true
-- end
-- end
-- if main == false then
-- table.insert(maint, z)
-- end
--end
--for i, item in ipairs(maint) do
-- print(item)
-- end
count_armor_of_type(armor, armortypes,maint)
--c = dfhack.script_environment('stocksfuncs').count_each(armor)
-- for i, item in ipairs(c) do
-- print(item)
-- end
end
function count_armor_of_type(armor, armortypes)
c = {}
--for b,mt in ipairs(maint) do
-- table.insert(c, mt)
--add maintypes
for i, item in ipairs(armortypes) do
count = 0;
oftype = {}
mats = {}
countMasterw = 0;
for j, k in ipairs(armor) do
--print(k._type)
if item == k.subtype.name then --k._type
count = count + 1
table.insert(oftype, k)
if k.getQuality(k) >= 5 then
countMasterw = countMasterw + 1
end
--print(k.getQuality(k))
end
end
for x,y in ipairs(oftype) do
--print(y)
end
v = dfhack.script_environment('stocksfuncs').count_each(oftype)
--print(item)
str = item:upper()..' total: '..count..' | '..countMasterw..'*'
--str = string.match(tostring(item),"<type: item_(.+)st>").." total: "..count..' | '..countMasterw.."*"
--str = dfhack.script_environment('stocksfuncs').get_type(item)..' total: '..count..' | '..countMasterw..'*'
-- print(str)
table.insert(c, str)
for x, y in ipairs(v) do
--print(y)
vstr = '----'..y
--print(vstr)
table.insert(c, vstr)
end
countMasterw = 0;
sep = ' '
table.insert(c, sep)
end
---end maintypes
-- end
print('-----------------------------------------------------------------')
print('Displaying stockpiled armor counts - Total | Masterwork/Artifact')
print('-----------------------------------------------------------------')
for i, item in ipairs(c) do
print(item)
end
end
find_armor()