Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("button")
- c1 = peripheral.wrap("container_chest_0")
- m = peripheral.wrap("top")
- m.clear()
- os.startTimer(1)
- rednet.open("right")
- message = "nothing"
- function prep()
- m.clear()
- m.setCursorPos(22,14)
- m.write("Counting")
- for i = 2,49 do
- m.setCursorPos(i,15)
- m.write("_")
- end
- for i = 2,49 do
- m.setCursorPos(i,17)
- m.write("-")
- end
- m.setCursorPos(1,16)
- m.write("|")
- m.setCursorPos(50,16)
- m.write("|")
- end
- function centerText(text, SQ)
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- length = string.len(text)
- x = 2
- x2 = 48
- y = 16
- y2 = 16
- Start = 48-2-length
- Middle = math.floor(Start/2)
- m.setCursorPos(3+Middle, 16)
- if SQ == Middle+3 or SQ > Middle+3 then
- m.setBackgroundColor(colors.green)
- elseif SQ < Middle+3 then
- m.setBackgroundColor(colors.black)
- end
- m.write(text)
- m.setBackgroundColor(colors.black)
- end
- function sort()
- prep()
- Overall = 0
- for i = 1,27 do
- if c1.getStackInSlot(i) then
- data = c1.getStackInSlot(i)
- num = data.qty
- print(num)
- Overall = Overall+num
- end
- end
- ItemsLeft = 0
- rednet.send(7,"Let's Do It!")
- IronOre = 0
- GoldOre = 0
- SilverOre = 0
- Diamond = 0
- LeadOre = 0
- CopperOre = 0
- TinOre = 0
- Coal = 0
- Lapis = 0
- FerrousOre = 0
- AluminumOre = 0
- Redstone = 0
- while message ~= "done" do
- event,id,message = os.pullEvent("rednet_message")
- print("message Received")
- print(message)
- if message == "count" then
- event,id,message = os.pullEvent("rednet_message")
- ItemsLeft = ItemsLeft + message
- Per = ItemsLeft/Overall
- Squares = Per*48
- Squares = math.floor(Squares)
- if Squares == 0 then
- SendText = ItemsLeft.."/"..Overall
- centerText(SendText, Squares)
- end
- for i = 1,Squares do
- m.setCursorPos(1,16)
- --m.clearLine()
- m.write("|")
- m.setCursorPos(50,16)
- m.write("|")
- m.setCursorPos(1+i,16)
- m.setBackgroundColor(colors.green)
- m.write(" ")
- m.setBackgroundColor(colors.black)
- SendText = ItemsLeft.."/"..Overall
- centerText(SendText, Squares)
- end
- if N == "Iron Ore" then
- IronOre = IronOre + message
- elseif N == "Gold Ore" then
- GoldOre = GoldOre + message
- elseif N == "Copper Ore" then
- CopperOre = CopperOre + message
- elseif N == "Tin Ore" then
- TinOre = TinOre + message
- elseif N == "Silver Ore" then
- SilverOre = SilverOre + message
- elseif N == "Lead Ore" then
- LeadOre = LeadOre + message
- elseif N == "Ferrous Ore" then
- FerrousOre = FerrousOre + message
- elseif N == "Redstone" then
- Redstone = Redstone + message
- elseif N == "Coal" then
- Coal = Coal + message
- end
- c1.condenseItems()
- elseif message == "prepare" then
- data = c1.getStackInSlot(1)
- N = data.display_name
- print(N)
- end
- end
- end
- function fillTable()
- button.setTable("Process",P,1,50,12,15)
- button.screen()
- end
- function P()
- button.clearTable()
- sort()
- end
- function getClick()
- event = {os.pullEvent()}
- if event[1] == "timer" and event[2] == timeout then
- os.startTimer(1)
- elseif event[1] == "rednet_message" then
- message = event[3]
- elseif event[1] == "monitor_touch" then
- x = event[3]
- y = event[4]
- button.checkxy(x,y)
- end
- end
- function setup()
- fillTable()
- button.heading("Nesie Processing System")
- end
- setup()
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement