Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("bottom")
- m = peripheral.wrap("right")
- m.setTextScale(0.5)
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.lightGray)
- term.setCursorBlink(false)
- m.clear()
- m.setCursorPos(1, 1)
- nocount = false
- seconds = 0
- minutes = 1
- checker = 1
- wantedItem = "abcomg"
- results2 = { 1, 2,3}
- local xBorder, yBorder = m.getSize()
- items = { }
- function clearscreen()
- m.clear()
- m.setCursorPos(1, 1)
- end
- function cursormovex()
- x, y = m.getCursorPos()
- x = x + 1
- m.setCursorPos(x, y)
- end
- function cursormovey()
- x, y = m.getCursorPos()
- y = y + 1
- m.setCursorPos(x, y)
- end
- function getcursor()
- x, y = m.getCursorPos()
- end
- function nextline()
- y = y + 1
- m.setCursorPos(x, y)
- end
- function saveCursor()
- a = x
- b = y
- end
- function restoreCursor()
- x = a
- y = b
- end
- -----------------------------
- function writetoTable(Table)
- if Table[itemName] == nil then
- Table[itemName] = 0
- end
- Table[itemName] = Table[itemName] + itemCount
- end
- function split(s, delimiter)
- result = {};
- for match in (s..delimiter):gmatch("(.-)"..delimiter) do
- table.insert(result, match);
- end
- return result;
- end
- function split2(s, delimiter)
- results2 = {};
- for match2 in (s..delimiter):gmatch("(.-)"..delimiter) do
- table.insert(results2, match2);
- end
- return results2;
- end
- function spairs(t, order)
- local keys = {}
- for k in pairs(t) do keys[#keys+1] = k end
- if order then
- table.sort(keys, function(a,b) return order(t, a, b) end)
- else
- table.sort(keys)
- end
- local i = 0
- return function()
- i = i + 1
- if keys[i] then
- return keys[i], t[keys[i]]
- end
- end
- end
- function calcAll()
- allItems = 0
- for k, v in pairs(items) do
- if k then
- allItems = allItems + v
- end
- end
- end
- function receive()
- senderID, message, protocol = rednet.receive()
- split(message, " ")
- itemName = tostring(result[1])
- itemCount= tonumber(result[2])
- meta = tonumber(result[3])
- itemName = string.match(itemName, ":(.*)")
- if itemName == "ender_pearl" then itemName = "ender pearl" end
- if itemName == "block_enderman_skull" then itemName = "enderman head" end
- if itemName == "item_item_conduit" then itemName = "item conduit" end
- if itemName == "item_extract_speed_upgrade" then itemName = "enderIO speed upgrade" end
- if itemName == "mob_ingredient" and meta == 11 then itemName = "nebulous heart" end
- if itemName == "mob_ingredient" and meta == 0 then itemName = "rib bone" end
- if itemName == "mob_ingredient" and meta == 1 then itemName = "withered rip" end
- if itemName == "mob_ingredient" and meta == 2 then itemName = "chelicerae" end
- if itemName == "mob_ingredient" and meta == 3 then itemName = "catalyzing gland" end
- if itemName == "mob_ingredient" and meta == 6 then itemName = "zombie heart" end
- if itemName == "mob_ingredient" and meta == 7 then itemName = "molten core" end
- if itemName == "stone" and meta == 5 then itemName = "andesite" end
- if itemName == "stone" and meta == 1 then itemName = "granite" end
- if itemName == "stone" and meta == 3 then itemName = "diorite" end
- if itemName == "dye" and meta == 0 then itemName = "ink sac" end
- if itemName == "dye" and meta == 4 then itemName = "lapis lazuli" end
- if itemName == "log" and meta == 0 then itemName = "oak wood" end
- if itemName == "beecomb" and meta == 13 then itemName = "watery comb" end
- if itemName == "bee_combs" and meta == 5 then itemName = "dripping comb" end
- if itemName == "bee_combs" and meta == 2 then itemName = "simmering comb" end
- if itemName == "bee_combs" and meta == 16 then itemName = "mellow comb" end
- if itemName == "bee_combs" and meta == 0 then itemName = "honey comb" end
- if itemName == "bee_combs" and meta == 7 then itemName = "parched comb" end
- if itemName == "honey_comb" and meta == 52 then itemName = "emerald comb" end
- if itemName == "honey_comb" and meta == 11 then itemName = "rocky comb" end
- if itemName == "wax" and meta == 0 then itemName = "magic wax" end
- if itemName == "material" and meta == 0 then itemName = "bitumen" end
- if itemName == "material" and meta == 771 then itemName = "sulfur" end
- if itemName == "material" and meta == 865 then itemName = "rich slag" end
- if itemName == "material" and meta == 866 then itemName = "cinnabar" end
- if itemName == "material" and meta == 128 then itemName = "copper ingot" end
- if itemName == "material" and meta == 129 then itemName = "tin ingot" end
- if itemName == "material" and meta == 130 then itemName = "silver ingot" end
- if itemName == "material" and meta == 131 then itemName = "lead ingot" end
- if itemName == "material" and meta == 132 then itemName = "aluminium ingot" end
- if itemName == "material" and meta == 133 then itemName = "nickel ingot" end
- if itemName == "material" and meta == 134 then itemName = "plat ingot" end
- if itemName == "material" and meta == 135 then itemName = "iridium ingot" end
- if itemName == "item_material" and meta == 20 then itemName = "infinity grain" end
- if itemName == "item_solidified_experience" then itemName = "solid exp" end
- writetoTable(items)
- --calcAll()
- --writeScreen()
- --print(itemName, itemCount)
- end
- function writeScreen()
- for k,v in spairs(items, function(t,a,b) return t[b] < t[a] end) do
- perSec = (v / zeituptime) * 60
- --fullperc = v / allItems * 100
- getcursor()
- if x == 1 then
- m.clearLine()
- end
- forcePosition()
- saveCursor()
- m.setTextColor(8192)
- m.setBackgroundColor(128)
- m.write(k)
- restoreCursor()
- nextline()
- saveCursor()
- m.setTextColor(128)
- m.setBackgroundColor(32768)
- m.write("[" ..v.. "]- ".. math.floor(perSec) .."/m" )
- --m.write("[" ..v.. "]-" .. math.floor(fullperc * 10 ) / 10 .. "%-".. perMin .."/m" )
- restoreCursor()
- nextline()
- end
- m.setCursorPos(1, 1)
- end
- function writeSelection(argus)
- if wantedItem == "abcomg" then
- m.clear()
- m.write("Input search in terminal")
- end
- for k,v in spairs(items, function(t,a,b) return t[b] < t[a] end) do
- for i=1, 5 do
- if results2[i] ~= nil then
- possibleitems = tostring(results2[i])
- if string.find(k, possibleitems) then
- --print(k)
- perSec = (v / zeituptime) * 60
- --fullperc = v / allItems * 100
- getcursor()
- if x == 1 then
- m.clearLine()
- end
- forcePosition()
- saveCursor()
- m.setTextColor(1)
- m.setBackgroundColor(128)
- m.write(k)
- restoreCursor()
- nextline()
- saveCursor()
- m.setTextColor(8192)
- m.setBackgroundColor(32768)
- m.write("[" ..v.. "]- ".. math.floor(perSec) .."/m" )
- restoreCursor()
- nextline()
- end
- end
- end
- end
- m.setCursorPos(1, 1)
- end
- function forcePosition()
- --print("y", y, "x", x)
- if y > (yBorder - 4) and x == 1 then
- m.setCursorPos(33, 1)
- getcursor()
- end
- if y > (yBorder - 4) and x == 33 then
- m.setCursorPos(67, 1)
- getcursor()
- end
- if y > (yBorder - 4) and x == 67 then
- m.setCursorPos(200, 1)
- getcursor()
- end
- end
- function reboot()
- getcursor()
- m.setCursorPos(93, 51)
- m.setBackgroundColor(16384)
- m.setTextColor(32768)
- m.write(" Reboot ")
- m.setBackgroundColor(32768)
- m.setCursorPos(93, 52)
- m.setBackgroundColor(16384)
- m.setTextColor(32768)
- m.write(" ")
- m.setBackgroundColor(32768)
- m.setTextColor(32)
- m.setCursorPos(x, y)
- end
- function searchmode()
- if showall == true then
- getcursor()
- m.clear()
- m.setCursorPos(1, 51)
- m.setBackgroundColor(2)
- m.setTextColor(32768)
- m.write(" Search ")
- m.setBackgroundColor(32768)
- m.setCursorPos(1, 52)
- m.setBackgroundColor(2)
- m.setTextColor(32768)
- m.write(" Mode ")
- m.setBackgroundColor(32768)
- m.setTextColor(32)
- m.setCursorPos(x, y)
- else
- getcursor()
- m.clear()
- m.setCursorPos(1, 51)
- m.setBackgroundColor(32)
- m.setTextColor(32768)
- m.write(" Show ")
- m.setBackgroundColor(32768)
- m.setTextColor(16)
- m.write(" Current")
- m.setCursorPos(1, 52)
- m.setBackgroundColor(32)
- m.setTextColor(32768)
- m.write(" All ")
- m.setBackgroundColor(32768)
- m.setTextColor(16)
- m.write(" search:")
- for i=1, 5 do
- if results2[i] ~= nil then
- m.write(" [" ..results2[i].."]")
- end
- end
- m.setCursorPos(x, y)
- end
- end
- function getMonitorTouch()
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- getcursor()
- --reboot button
- if (xPos >= 93) and (yPos >= 49) then
- os.reboot()
- end
- --search button
- if (xPos >= 1) and (xPos < 10) and (yPos >= 49) then
- if showall == true then
- showall = false
- searchmode()
- reboot()
- elseif showall == false then
- showall = true
- searchmode()
- reboot()
- end
- end
- end
- function uptime()
- while true do
- if showall == true then
- writeScreen()
- else
- writeSelection(wantedItem)
- --print(wantedItem)
- end
- zeituptime = os.clock()
- --print(zeituptime)
- minutesu = math.floor(zeituptime / 60)
- hoursu = math.floor(minutesu / 60)
- secondsu = math.floor(zeituptime - minutesu * 60)
- displayminutes = math.floor(minutesu - hoursu * 60)
- getcursor()
- m.setCursorPos(76, 51)
- m.setTextColor(1)
- m.write("Computer uptime:")
- m.setCursorPos(81, 52)
- m.write(hoursu.. "h" ..displayminutes.. "m" ..secondsu.."s")
- m.setCursorPos(x, y)
- sleep(1)
- searchmode()
- reboot()
- --print(items["ender pearl"])
- end
- end
- function takeinput()
- --print("Input search: ")
- --term.setCursorPos(1, 2)
- term.setCursorBlink(false)
- wantedItem = read()
- showall = false
- searchmode()
- term.setCursorBlink(false)
- term.clear()
- term.setCursorPos(1, 1)
- split2(wantedItem, " ")
- searchmode()
- reboot()
- end
- showall = true
- reboot()
- while true do
- parallel.waitForAny(receive, getMonitorTouch, uptime, takeinput)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement