SHOW:
|
|
- or go back to the newest paste.
| 1 | -- Modified by HPWebcamAble for CC 1.5 | |
| 2 | ||
| 3 | -- Based on direwolf20 thaumcraft essentia/request monitor updated by Bart1ebee | |
| 4 | -- Button API (XBbMUYNn) by direwolf20 | |
| 5 | -- Working with 1.7.10 tested with versions below | |
| 6 | -- Thaumcraft-1.7.10-4.2.3.5 | |
| 7 | -- ThaumicTinkerer-2.5-1.7.10-439 | |
| 8 | -- ComputerCraft 1.65 | |
| 9 | -- OpenPeripheralAddons-1.7.10-0.2.0-snapshot-149 | |
| 10 | -- Works with crystallized essentia should work with mana beans | |
| 11 | -- Thanks to direwolf20 for initially writing the program. | |
| 12 | - | --rednet.open("left")
|
| 12 | + | |
| 13 | ||
| 14 | - | --local turtleID = 40 |
| 14 | + | local pipe = peripheral.wrap("LogisticsPipes:Request")
|
| 15 | local m = peripheral.wrap("right")
| |
| 16 | ||
| 17 | - | local m = peripheral.find("monitor")
|
| 17 | + | |
| 18 | local essentia = {}
| |
| 19 | local jars = peripheral.getNames() | |
| 20 | local monCoord = {}
| |
| 21 | local currEssentia | |
| 22 | - | local pipe = peripheral.find("LogisticsPipes:Request")
|
| 22 | + | |
| 23 | local rowsActive = true | |
| 24 | local beans = {}
| |
| 25 | ||
| 26 | function findBeans() | |
| 27 | data = pipe.getAvailableItems() | |
| 28 | for i=1,#data do | |
| 29 | data2 = data[i].getValue1().getTagCompound() | |
| 30 | beans[data2["value"]["Aspects"]["value"][1]["value"]["key"]["value"]] = data[i].getValue1() | |
| 31 | end | |
| 32 | -- print(beans["instrumentum"][1]) | |
| 33 | end | |
| 34 | ||
| 35 | function sortEss(t) | |
| 36 | local keys = {}
| |
| 37 | for k in pairs(t) do keys[#keys+1] = k end | |
| 38 | table.sort(keys) | |
| 39 | ||
| 40 | local i = 0 | |
| 41 | return function() | |
| 42 | i = i+1 | |
| 43 | if keys[i] then | |
| 44 | return keys[i], t[keys[i]] | |
| 45 | end | |
| 46 | end | |
| 47 | end | |
| 48 | ||
| 49 | function scanEssentia() | |
| 50 | for i,j in ipairs(jars) do | |
| 51 | if peripheral.getType(j) == "tt_aspectContainer" then | |
| 52 | asp = peripheral.call(j, "getAspects") | |
| 53 | print(asp) | |
| 54 | countasp = peripheral.call(j, "getAspectCount", asp[1]) | |
| 55 | if countasp > 0 then | |
| 56 | essentia[asp[1]] = math.floor(countasp) | |
| 57 | end | |
| 58 | -- print(countasp) | |
| 59 | -- print(asp[1]..":"..countasp) | |
| 60 | -- print(peripheral.getType(j)) | |
| 61 | end | |
| 62 | end | |
| 63 | end | |
| 64 | ||
| 65 | function printEssentia() | |
| 66 | m.setTextColor(colors.white) | |
| 67 | local x = 1 | |
| 68 | local y = 1 | |
| 69 | monCoord[x] = {}
| |
| 70 | -- for a = 1,17 do | |
| 71 | for i,j in sortEss(essentia) do | |
| 72 | if j<=20 then m.setTextColor(colors.red) end | |
| 73 | if j<40 and j>20 then m.setTextColor(colors.yellow) end | |
| 74 | if j>=40 then m.setTextColor(colors.green) end | |
| 75 | ||
| 76 | m.setCursorPos(x,y) | |
| 77 | m.write(i) | |
| 78 | m.setCursorPos(x+14,y) | |
| 79 | m.write(tostring(j)) | |
| 80 | -- print(j) | |
| 81 | monCoord[x][y] = i | |
| 82 | if y < 17 then | |
| 83 | y = y+1 | |
| 84 | else | |
| 85 | y = 1 | |
| 86 | x = x+17 | |
| 87 | monCoord[x] = {}
| |
| 88 | end | |
| 89 | end | |
| 90 | -- end | |
| 91 | m.setTextColor(colors.white) | |
| 92 | end | |
| 93 | ||
| 94 | function getClick() | |
| 95 | local event,side,x,y = os.pullEvent() | |
| 96 | if event=="monitor_touch" then | |
| 97 | if button.checkxy(x,y) then | |
| 98 | print("button")
| |
| 99 | else | |
| 100 | if rowsActive then | |
| 101 | fillAmt = 0 | |
| 102 | print(x..":"..x-(x%17)+1) | |
| 103 | print(monCoord[x-(x%17)+1][y]) | |
| 104 | currEssentia = monCoord[x-(x%17)+1][y] | |
| 105 | if currEssentia ~= nil then | |
| 106 | if essentia[currEssentia] < 64 then | |
| 107 | fillTable2() | |
| 108 | else | |
| 109 | m.clear() | |
| 110 | button.label(1,10, currEssentia.." is already full. Please choose another.") | |
| 111 | sleep(3) | |
| 112 | refresh() | |
| 113 | end | |
| 114 | end | |
| 115 | end | |
| 116 | end | |
| 117 | end | |
| 118 | end | |
| 119 | ||
| 120 | function refresh() | |
| 121 | button.flash("Refresh")
| |
| 122 | m.clear() | |
| 123 | scanEssentia() | |
| 124 | printEssentia() | |
| 125 | print("Refreshed")
| |
| 126 | button.screen() | |
| 127 | end | |
| 128 | ||
| 129 | function fillTable() | |
| 130 | rowsActive = true | |
| 131 | button.clearTable() | |
| 132 | button.setTable("Refresh", refresh, "", 15, 35, 19, 19)
| |
| 133 | button.screen() | |
| 134 | end | |
| 135 | ||
| 136 | function addEss(num) | |
| 137 | fillAmt = fillAmt + num | |
| 138 | if fillAmt < 0 then fillAmt = 0 end | |
| 139 | if fillAmt > 64-essentia[currEssentia] then fillAmt = 64-essentia[currEssentia] end | |
| 140 | m.clear() | |
| 141 | fillTable2() | |
| 142 | end | |
| 143 | ||
| 144 | function fillEss2() | |
| 145 | pipe.makeRequest(beans[currEssentia], fillAmt) | |
| 146 | m.clear() | |
| 147 | fillTable() | |
| 148 | refresh() | |
| 149 | end | |
| 150 | ||
| 151 | function fillEss() | |
| 152 | --No longer used, see fillEss2() | |
| 153 | local essData = {}
| |
| 154 | essData[1] = currEssentia | |
| 155 | essData[2] = fillAmt | |
| 156 | local sendData = "" | |
| 157 | sendData = textutils.serialize(essData) | |
| 158 | rednet.send(turtleID, sendData) | |
| 159 | m.clear() | |
| 160 | button.label(7, 10, "Waiting for aspects to finish cooking....") | |
| 161 | button.label(7, 12, "Don't forget to refresh the screen after") | |
| 162 | button.label(7, 13, "the golem is done moving the essentia.") | |
| 163 | rednet.receive() | |
| 164 | m.clear() | |
| 165 | fillTable() | |
| 166 | refresh() | |
| 167 | end | |
| 168 | ||
| 169 | function cancel() | |
| 170 | m.clear() | |
| 171 | fillTable() | |
| 172 | refresh() | |
| 173 | end | |
| 174 | ||
| 175 | function fillTable2() | |
| 176 | rowsActive = false | |
| 177 | button.clearTable() | |
| 178 | m.clear() | |
| 179 | button.label(7, 1, "Essentia: "..currEssentia.." contains "..essentia[currEssentia]) | |
| 180 | button.setTable("+1", addEss, 1, 8, 18, 6,6)
| |
| 181 | button.setTable("+5", addEss, 5, 20, 30, 6, 6)
| |
| 182 | button.setTable("+10", addEss, 10, 32, 42, 6, 6)
| |
| 183 | button.setTable("-1", addEss, -1, 8, 18, 8, 8)
| |
| 184 | button.setTable("-5", addEss, -5, 20, 30, 8, 8)
| |
| 185 | button.setTable("-10", addEss, -10, 32, 42, 8 ,8)
| |
| 186 | button.setTable("Refill Jar", addEss, 64-essentia[currEssentia], 8, 42, 10, 10)
| |
| 187 | button.setTable("Execute Fill Request", fillEss2, "", 8, 42, 16, 18)
| |
| 188 | button.setTable("Cancel", cancel, "", 20, 30, 12, 14)
| |
| 189 | button.label(7, 4, "Currently Adding "..fillAmt.." "..currEssentia.." essentia.") | |
| 190 | button.screen() | |
| 191 | end | |
| 192 | ||
| 193 | fillTable() | |
| 194 | refresh() | |
| 195 | findBeans() | |
| 196 | while true do getClick() end |