-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplayMEItems
170 lines (147 loc) · 4.1 KB
/
displayMEItems
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
args = {...}
local itemsOfInterest = {}
local counterWindow = nil
local totalValueIndent = 3
local updateDifIndent = 8
local updateEachSeconds = 60
local textPositions = {
["name"] = 1,
["total"] = 15,
["updateDif"] = 25,
["perSec"] = 35,
}
function putItemOfInterest(displayName, id, dmg)
table.insert(itemsOfInterest, {
["name"] = displayName,
["id"] = id,
["dmg"] = dmg,
["lastValue"] = 0,
["window"] = nil,
})
end
function updateWindow(item, MEData)
local window = item.window
local oldAmount = item.lastValue
local newAmount = MEData.size
local changed = newAmount - oldAmount
local prefix = "+"
local changeColour = colors.green
if changed < 0 then
prefix = ""
changeColour = colors.red
end
item.lastValue = newAmount
window.clear()
window.setCursorPos(textPositions.name, 1)
window.write(item.name)
window.setCursorPos(textPositions.total, 1)
window.write(MEData.size)
window.setCursorPos(textPositions.updateDif, 1)
window.setTextColor(changeColour)
window.write(prefix..(newAmount-oldAmount))
window.setTextColor(colors.white)
window.setCursorPos(textPositions.perSec, 1)
window.setTextColor(changeColour)
window.write(prefix..((newAmount-oldAmount)/updateEachSeconds))
window.setTextColor(colors.white)
end
function setupItemWindows(monitor, columns, rows, posX, posY, sizeToUseX, sizeToUseY)
local individualSizeX = sizeToUseX/columns
local individualSizeY = sizeToUseY/rows
local curIndex = 1
for c=1, columns do
for r=1, rows do
itemsOfInterest[curIndex].window = window.create(monitor, posX+(c-1)*individualSizeX, posY+(r-1)*individualSizeY, individualSizeX, individualSizeY)
curIndex = curIndex + 1
end
end
end
function setupMonitor(monitor)
local curY = 6
local monitorSizeX, monitorSizeY = monitor.getSize()
local columns = 1
local rows = #itemsOfInterest/columns
monitor.clear()
for i=1, columns do
local headline = window.create(monitor, 1+(i-1)*(monitorSizeX/columns), curY, monitorSizeX/columns, 1)
headline.clear()
headline.setCursorPos(textPositions.name, 1)
headline.write("Type")
headline.setCursorPos(textPositions.total, 1)
headline.write("Total")
headline.setCursorPos(textPositions.updateDif, 1)
headline.write("Per "..updateEachSeconds.."s")
headline.setCursorPos(textPositions.perSec, 1)
headline.write("Per second")
end
curY = curY + 2
setupItemWindows(monitor, columns, rows, 1, curY, monitorSizeX-1, #itemsOfInterest/columns)
counterWindow = window.create(monitor, 1, monitorSizeY, monitorSizeX, 1)
end
local ae = peripheral.find("aemultipart") or peripheral.find("tilecontroller") or peripheral.wrap("back") or peripheral.find("tileinterface")
if not ae then
print("AE not found")
return
end
local monitor = peripheral.find("monitor")
if not monitor then
print("monitor not found")
return
end
--init interesting items
putItemOfInterest("Diamond", "minecraft:diamond", 0)
putItemOfInterest("Emerald", "minecraft:emerald", 0)
putItemOfInterest("Gold Ingot", "minecraft:gold_ingot", 0)
putItemOfInterest("Iron Ingot", "minecraft:iron_ingot", 0)
putItemOfInterest("Ender Pearl", "minecraft:ender_pearl", 0)
putItemOfInterest("Blaze Rod", "minecraft:blaze_rod", 0)
putItemOfInterest("Yellorium", "BigReactors:BRIngot", 0)
setupMonitor(monitor)
while true do
local var = ae.getAvailableItems()
for i=1, #var do
for _, interestingItem in ipairs(itemsOfInterest) do
if var[i].fingerprint.id == interestingItem.id then
if var[i].fingerprint.dmg == interestingItem.dmg then
updateWindow(interestingItem, var[i])
break
end
end
end
end
for i=updateEachSeconds-1, 0, -1 do
os.sleep(1)
counterWindow.clear()
counterWindow.setCursorPos(1, 1)
counterWindow.write("Next update in "..i.." seconds")
end
end
--[[
AE uses:
item objects {
size:number
is_item:boolean
is_fluid:boolean
is_craftable:boolean
fingerprint:table {
id: minecraft:dirt
dmg:number
nbt_hash:hash
}
}
vanilla chst use:
item stacks {
display_name = "Birch Wood",
qty = 1, --quantity
max_size = 64,
max_dmg = 0,
raw_name = "tile.log.birch",
burn_time = 300,
dmg = 2,
ore_dict = {
logWood = true,
},
name = "log",
mod_id = "minecraft"
}
]]