Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- print("Hosting...")
- rednet.host("arcGuard", "arcMonitor")
- print("Ready !")
- print("Guardian Controller v4")
- term.redirect(peripheral.find("monitor"))
- monX, monY = term.getSize()
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- term.setCursorPos(1, 1)
- paintutils.drawLine(1, 1, monX, 1, colors.gray)
- paintutils.drawPixel(1, 1, colors.blue)
- paintutils.drawPixel(monX, 1, colors.blue)
- term.setCursorPos(1, 1)
- term.write("<")
- term.setCursorPos(monX, 1)
- term.write(">")
- term.setBackgroundColor(colors.gray)
- term.setCursorPos((monX / 2) - (string.len("Prismarine Shard") / 2), 1)
- term.write("Prismarine Shard")
- currentItem = 1
- currentSubItem = 0
- itemList = {"Prismarine Shard", "Prismarine Crystal", "Fish", "Guardian Pearl"}
- currentItemStr = itemList[currentItem]
- serverList = {3955, 3953, 3954, 3978}
- serverSubList = {4320, 4319}
- currentItemQuantity = 64
- currentItemQuantity = math.ceil(currentItemQuantity)
- paintutils.drawFilledBox(1, 2, monX / 3 + 1, monY, colors.lightBlue)
- term.setCursorPos(1, 2)
- term.write("Arborescence")
- term.setCursorPos(3, 3)
- term.write(itemList[1])
- term.setCursorPos(3, 4)
- term.write(itemList[2])
- term.setCursorPos(3, 5)
- term.write(itemList[3])
- term.setCursorPos(3, 6)
- term.write(itemList[4])
- oldColor = term.getTextColor()
- term.setTextColor(colors.yellow)
- term.setCursorPos(1, 3)
- term.write(">")
- term.setTextColor(oldColor)
- paintutils.drawFilledBox(monX / 3 + 3, 3, monX / 3 + 7, 5, colors.red)
- term.setCursorPos(monX / 3 + 4, 4)
- term.write("-1")
- paintutils.drawFilledBox(monX / 3 + 3, monY - 3, monX / 3 + 7, monY - 1, colors.green)
- term.setCursorPos(monX / 3 + 4, monY - 2)
- term.write("+1")
- paintutils.drawFilledBox(monX / 3 + 9, 3, monX / 3 + 13, 5, colors.red)
- term.setCursorPos(monX / 3 + 10, 4)
- term.write("-16")
- paintutils.drawFilledBox(monX / 3 + 9, monY - 3, monX / 3 + 13, monY - 1, colors.green)
- term.setCursorPos(monX / 3 + 10, monY - 2)
- term.write("+16")
- paintutils.drawFilledBox(monX / 3 + 15, 3, monX / 3 + 19, 5, colors.red)
- term.setCursorPos(monX / 3 + 16, 4)
- term.write("-32")
- paintutils.drawFilledBox(monX / 3 + 15, monY - 3, monX / 3 + 19, monY - 1, colors.green)
- term.setCursorPos(monX / 3 + 16, monY - 2)
- term.write("+32")
- paintutils.drawFilledBox(monX / 3 + 21, 3, monX / 3 + 25, 5, colors.red)
- term.setCursorPos(monX / 3 + 22, 4)
- term.write("-64")
- paintutils.drawFilledBox(monX / 3 + 21, monY - 3, monX / 3 + 25, monY - 1, colors.green)
- term.setCursorPos(monX / 3 + 22, monY - 2)
- term.write("+64")
- paintutils.drawLine(monX / 3 + 3, monY / 2 + 1, monX, monY / 2 + 1, colors.lightGray)
- term.setCursorPos(monX / 3 + 3, monY / 2 + 1)
- term.write("Commande : "..tostring(currentItemQuantity))
- paintutils.drawFilledBox(monX / 3 + 27, monY - 3, monX - 1, monY - 1, colors.yellow)
- term.setCursorPos(monX / 3 + 30, monY - 2)
- term.write("Commander")
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(1, monY - 1)
- term.write("Quantité :")
- levelServerList = {4098, 4099, 4100, 4101}
- if currentItem == 1 then
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(3, 8)
- term.setTextColor(colors.yellow)
- term.write("+")
- term.setTextColor(colors.white)
- term.setCursorPos(6, 8)
- term.write("Prismarine")
- term.setCursorPos(6, 9)
- term.write("Pris. Bricks")
- else
- paintutils.drawFilledBox(1, 8, monX / 3 + 1, 10, colors.lightBlue)
- end
- function setCursorList(cursorPos)
- paintutils.drawLine(1, 3, 1, 6, colors.lightBlue)
- term.setTextColor(colors.yellow)
- term.setCursorPos(1, cursorPos + 2)
- term.write(">")
- term.setTextColor(oldColor)
- paintutils.drawLine(4, 8, 4, 9, colors.lightBlue)
- end
- function changeItem(itemStr)
- if itemStr == "+" then
- if currentItem >= 4 then
- currentItem = 1
- currentItemStr = itemList[currentItem]
- paintutils.drawLine(2, 1, monX - 1, 1, colors.gray)
- term.setCursorPos((monX / 2) - (string.len(currentItemStr) / 2), 1)
- term.write(currentItemStr)
- else
- currentItem = currentItem + 1
- currentItemStr = itemList[currentItem]
- paintutils.drawLine(2, 1, monX - 1, 1, colors.gray)
- term.setCursorPos((monX / 2) - (string.len(currentItemStr) / 2), 1)
- term.write(currentItemStr)
- end
- elseif itemStr == "-" then
- if currentItem <= 1 then
- currentItem = 4
- currentItemStr = itemList[currentItem]
- paintutils.drawLine(2, 1, monX - 1, 1, colors.gray)
- term.setCursorPos((monX / 2) - (string.len(currentItemStr) / 2), 1)
- term.write(currentItemStr)
- else
- currentItem = currentItem - 1
- currentItemStr = itemList[currentItem]
- paintutils.drawLine(2, 1, monX - 1, 1, colors.gray)
- term.setCursorPos((monX / 2) - (string.len(currentItemStr) / 2), 1)
- term.write(currentItemStr)
- end
- end
- setCursorList(currentItem)
- if currentItem == 4 and currentItemQuantity > 16 then
- currentItemQuantity = 16
- currentItemQuantity = math.ceil(currentItemQuantity)
- paintutils.drawLine(monX / 3 + 3, monY / 2 + 1, monX, monY / 2 + 1, colors.lightGray)
- term.setCursorPos(monX / 3 + 3, monY / 2 + 1)
- term.write("Commande : "..tostring(currentItemQuantity))
- end
- currentSubItem = 0
- end
- function setItem(itemPos)
- itemPos = itemPos - 2
- setCursorList(itemPos)
- currentItem = itemPos
- currentItemStr = itemList[currentItem]
- paintutils.drawLine(2, 1, monX - 1, 1, colors.gray)
- term.setCursorPos((monX / 2) - (string.len(currentItemStr) / 2), 1)
- term.write(currentItemStr)
- if currentItem == 4 and currentItemQuantity > 16 then
- currentItemQuantity = 16
- currentItemQuantity = math.ceil(currentItemQuantity)
- paintutils.drawLine(monX / 3 + 3, monY / 2 + 1, monX, monY / 2 + 1, colors.lightGray)
- term.setCursorPos(monX / 3 + 3, monY / 2 + 1)
- term.write("Commande : "..tostring(currentItemQuantity))
- end
- currentSubItem = 0
- end
- function changeQuantity(newQuantity)
- if newQuantity == "-1" then
- currentItemQuantity = currentItemQuantity - 1
- if currentItemQuantity < 1 then
- currentItemQuantity = 1
- end
- elseif newQuantity == "+1" then
- currentItemQuantity = currentItemQuantity + 1
- if currentItemQuantity > 64 then
- currentItemQuantity = 64
- end
- elseif newQuantity == "-16" then
- currentItemQuantity = currentItemQuantity - 16
- if currentItemQuantity < 1 then
- currentItemQuantity = 1
- end
- elseif newQuantity == "+16" then
- currentItemQuantity = currentItemQuantity + 16
- if currentItemQuantity > 64 then
- currentItemQuantity = 64
- end
- elseif newQuantity == "-32" then
- currentItemQuantity = currentItemQuantity - 32
- if currentItemQuantity < 1 then
- currentItemQuantity = 1
- end
- elseif newQuantity == "+32" then
- currentItemQuantity = currentItemQuantity + 32
- if currentItemQuantity > 64 then
- currentItemQuantity = 64
- end
- elseif newQuantity == "-64" then
- currentItemQuantity = currentItemQuantity - 64
- if currentItemQuantity < 1 then
- currentItemQuantity = 1
- end
- elseif newQuantity == "+64" then
- currentItemQuantity = currentItemQuantity + 64
- if currentItemQuantity > 64 then
- currentItemQuantity = 64
- end
- end
- if currentItem == 4 and currentItemQuantity > 16 then
- currentItemQuantity = 16
- end
- currentItemQuantity = math.ceil(currentItemQuantity)
- paintutils.drawLine(monX / 3 + 3, monY / 2 + 1, monX, monY / 2 + 1, colors.lightGray)
- term.setCursorPos(monX / 3 + 3, monY / 2 + 1)
- term.write("Commande : "..tostring(currentItemQuantity))
- end
- function buttonHandler()
- while true do
- event, button, mouseX, mouseY = os.pullEvent("monitor_touch")
- if mouseX <= monX / 3 + 1 and mouseY == 8 and currentItem == 1 then
- paintutils.drawLine(1, 3, 1, 6, colors.lightBlue)
- paintutils.drawLine(4, 8, 4, 9, colors.lightBlue)
- term.setTextColor(colors.yellow)
- term.setCursorPos(4, 8)
- term.write(">")
- term.setTextColor(oldColor)
- currentSubItem = 1
- elseif mouseX <= monX / 3 + 1 and mouseY == 9 and currentItem == 1 then
- paintutils.drawLine(1, 3, 1, 6, colors.lightBlue)
- paintutils.drawLine(4, 8, 4, 9, colors.lightBlue)
- term.setTextColor(colors.yellow)
- term.setCursorPos(4, 9)
- term.write(">")
- term.setTextColor(oldColor)
- currentSubItem = 2
- elseif mouseX == 1 and mouseY == 1 then
- changeItem("-")
- elseif mouseX == monX and mouseY == 1 or mouseX == monX - 1 and mouseY == 1 or mouseX == monX and mouseY == 2 or mouseX == monX - 1 and mouseY == 2 then
- changeItem("+")
- elseif mouseX <= monX / 3 + 1 and mouseY <= 6 and mouseY >= 3 then
- setItem(mouseY)
- elseif mouseX <= monX / 3 + 7 and mouseX >= monX / 3 + 3 and mouseY <= 5 and mouseY >= 3 then
- changeQuantity("-1")
- elseif mouseX <= monX / 3 + 7 and mouseX >= monX / 3 + 3 and mouseY <= monY - 1 and mouseY >= monY - 3 then
- changeQuantity("+1")
- elseif mouseX <= monX / 3 + 13 and mouseX >= monX / 3 + 9 and mouseY <= 5 and mouseY >= 3 then
- changeQuantity("-16")
- elseif mouseX <= monX / 3 + 13 and mouseX >= monX / 3 + 9 and mouseY <= monY - 1 and mouseY >= monY - 3 then
- changeQuantity("+16")
- elseif mouseX <= monX / 3 + 19 and mouseX >= monX / 3 + 15 and mouseY <= 5 and mouseY >= 3 then
- changeQuantity("-32")
- elseif mouseX <= monX / 3 + 19 and mouseX >= monX / 3 + 15 and mouseY <= monY - 1 and mouseY >= monY - 3 then
- changeQuantity("+32")
- elseif mouseX <= monX / 3 + 25 and mouseX >= monX / 3 + 21 and mouseY <= 5 and mouseY >= 3 then
- changeQuantity("-64")
- elseif mouseX <= monX / 3 + 25 and mouseX >= monX / 3 + 21 and mouseY <= monY - 1 and mouseY >= monY - 3 then
- changeQuantity("+64")
- elseif mouseX <= monX - 1 and mouseX >= monX / 3 + 27 and mouseY <= monY - 1 and mouseY >= monY - 3 then
- if currentSubItem == 0 then
- rednet.send(serverList[currentItem], tostring(currentItemQuantity))
- else
- rednet.send(serverSubList[currentSubItem], tostring(currentItemQuantity))
- end
- end
- if currentItem == 1 then
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(3, 8)
- term.setTextColor(colors.yellow)
- term.write("+")
- term.setTextColor(colors.white)
- term.setCursorPos(6, 8)
- term.write("Prismarine")
- term.setCursorPos(6, 9)
- term.write("Pris. Bricks")
- else
- paintutils.drawFilledBox(1, 8, monX / 3 + 1, 10, colors.lightBlue)
- end
- end
- end
- function levelHandler()
- while true do
- id, msg = rednet.receive("arcGuard")
- if id == levelServerList[currentItem] then
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(1, monY)
- pxLine = tonumber(msg)
- pxLine = (pxLine * (monX / 3 + 1)) / 15
- paintutils.drawLine(1, monY, monX / 3 + 1, monY, colors.lightBlue)
- if pxLine == 0 then
- paintutils.drawLine(1, monY, pxLine, monY, colors.red)
- term.setCursorPos(1, monY)
- term.setTextColor(colors.orange)
- term.write("0")
- term.setTextColor(colors.white)
- else
- paintutils.drawLine(1, monY, pxLine, monY, colors.cyan)
- end
- end
- end
- end
- parallel.waitForAny(buttonHandler, levelHandler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement