Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- os.loadAPI("button")
- local m = term
- local areaShown = false
- local homex = -847
- local homey = 168
- local homez = 970
- local setx = 0
- local sety = 0
- local setz = 0
- local setx2 = 0
- local sety2 = 0
- local setz2 = 0
- local currx = 0
- local curry = 0
- local currz = 0
- local chestx = 0
- local chesty = 0
- local chestz = 0
- local menuType = "mainMenu"
- local areaType = "Filled"
- local moveMode = "Normal"
- function sendMessage(message)
- rednet.send(59, message)
- end
- function mainMenu()
- m.clear()
- button.clearTable()
- button.setTable("Come Here", comeHere, "", 3, 13, 1, 1)
- button.setTable("Go Home", goHome, "", 15, 25, 1, 1)
- button.setTable("Set Area", setXYZMenu, "", 3, 13, 3, 3)
- button.setTable("GoTo", goTo, "", 15, 25, 3, 3)
- button.setTable("Dig", dig, "", 3, 13, 5, 5)
- button.setTable("Get Pick", getPickaxe, "", 15, 25, 5, 5)
- button.setTable("Pickup", pickup, "", 3, 13, 7, 7)
- button.setTable("GetItems", getItems, "", 15, 25, 7, 7)
- button.setTable("ItemsChest", dropItems, "", 15, 25, 9, 9)
- button.setTable("Attack", attack, "", 3, 13, 9, 9)
- button.setTable("Build", place, "", 3, 13, 11, 11)
- button.setTable("Set Chest", setChest, "", 3, 13, 16, 16)
- button.setTable("Show Area", showAreaToggle, "", 15, 25, 18, 18)
- button.setTable("Status", setStatusMenu, "", 3, 13, 18, 18)
- if chesty ~= 0 then
- button.toggleButton("Set Chest")
- end
- button.setButton("Show Area", areaShown)
- button.screen()
- end
- function statusMenu()
- local x,y,z = getPosition()
- m.clear()
- button.clearTable()
- button.setTable("Back", setMainMenu, "", 1, 6, 1, 1)
- button.setTable("Refresh", displayScreen, "", 2, 25, 20,20)
- button.label(1,3,"Pressure: "..getPressure())
- button.label(1,4,"Position: "..math.floor(x)..","..math.floor(y)..","..math.floor(z))
- button.label(1,5,"Action: "..tostring(not isDone()))
- -- button.label(1,6,"Pickaxe: "..tostring(hasPickaxe()))
- button.screen()
- end
- function xyzMenu()
- m.clear()
- button.clearTable()
- button.label(1,1,"Position: "..currx..","..curry..","..currz)
- button.setTable("Back", setMainMenu, "", 1, 6, 2, 2)
- button.setTable(moveMode, toggleMoveMode, "", 10, 20, 2, 2)
- button.label(1,4,"X: ")
- button.setTable("x-10", changeX, -10, 4, 7, 4, 4)
- button.setTable("x-1", changeX, -1, 9, 11, 4, 4)
- button.label(15, 4, setx)
- button.setTable("x+1", changeX, 1, 18, 20, 4, 4)
- button.setTable("x+10", changeX, 10, 22, 25, 4, 4)
- button.label(1,6,"Y: ")
- button.setTable("y-10", changeY, -10, 4, 7, 6, 6)
- button.setTable("y-1", changeY, -1, 9, 11, 6, 6)
- button.label(15, 6, sety)
- button.setTable("y+1", changeY, 1, 18, 20, 6, 6)
- button.setTable("y+10", changeY, 10, 22, 25, 6, 6)
- button.label(1,8,"Z: ")
- button.setTable("z-10", changeZ, -10, 4, 7, 8, 8)
- button.setTable("z-1", changeZ, -1, 9, 11, 8, 8)
- button.label(15, 8, setz)
- button.setTable("z+1", changeZ, 1, 18, 20, 8, 8)
- button.setTable("z+10", changeZ, 10, 22, 25, 8, 8)
- if moveMode == "Normal" then
- button.label(1,10,"X2: ")
- button.setTable("a-10", changeX2, -10, 4, 7, 10, 10)
- button.setTable("a-1", changeX2, -1, 9, 11, 10, 10)
- button.label(15, 10, setx2)
- button.setTable("a+1", changeX2, 1, 18, 20, 10, 10)
- button.setTable("a+10", changeX2, 10, 22, 25, 10, 10)
- button.label(1,12,"Y2: ")
- button.setTable("b-10", changeY2, -10, 4, 7, 12, 12)
- button.setTable("b-1", changeY2, -1, 9, 11, 12, 12)
- button.label(15, 12, sety2)
- button.setTable("b+1", changeY2, 1, 18, 20, 12, 12)
- button.setTable("b+10", changeY2, 10, 22, 25, 12, 12)
- button.label(1,14,"Z2: ")
- button.setTable("c-10", changeZ2, -10, 4, 7, 14, 14)
- button.setTable("c-1", changeZ2, -1, 9, 11, 14, 14)
- button.label(15, 14, setz2)
- button.setTable("c+1", changeZ2, 1, 18, 20, 14, 14)
- button.setTable("c+10", changeZ2, 10, 22, 25, 14, 14)
- end
- button.setTable("Reset", resetXYZ, "", 10, 20, 16, 16)
- button.setTable(areaType, toggleAreaType, "", 3, 13, 18, 18)
- button.setTable("Show Area", showAreaToggle, "", 15, 25, 18, 18)
- button.setTable("Clear Area", clearArea, "", 3, 13, 20, 20)
- button.setTable("Apply", refreshArea, "", 15, 25, 20, 20)
- button.setButton("Show Area", areaShown)
- button.screen()
- end
- function toggleMoveMode()
- if moveMode == "Normal" then
- moveMode = "Move"
- elseif moveMode == "Move" then
- moveMode = "Expand"
- elseif moveMode == "Expand" then
- moveMode = "Normal"
- end
- end
- function getPressure()
- local data = {}
- data[0] = "getPressure"
- sendMessage(textutils.serialize(data))
- local id, message, distance, protocol = rednet.receive(5)
- return(message)
- end
- function getPosition()
- local data = {}
- data[0] = "getPosition"
- sendMessage(textutils.serialize(data))
- local id, message, distance, protocol = rednet.receive(5)
- local returnData = textutils.unserialize(message)
- return returnData[1], returnData[2], returnData[3]
- end
- function toggleAreaType()
- if areaType == "Filled" then
- areaType = "Frame"
- elseif areaType == "Frame" then
- areaType = "Walls"
- elseif areaType == "Walls" then
- areaType = "Filled"
- else
- areaType = "Filled"
- end
- refreshArea()
- end
- function resetXYZ()
- setx = 0
- sety = 0
- setz = 0
- setx2 = 0
- sety2 = 0
- setz2 = 0
- currx,curry,currz = gpsLocate()
- refreshArea()
- end
- function setXYZMenu()
- if curry==0 then
- currx,curry,currz = gpsLocate()
- end
- menuType = "xyzMenu"
- end
- function setMainMenu()
- menuType = "mainMenu"
- end
- function setStatusMenu()
- menuType = "statusMenu"
- end
- function refreshArea()
- setAreaGlobal()
- showArea(false)
- showArea(true)
- areaShown = true
- end
- function setChest()
- chestx = currx+setx
- chesty = curry+sety
- chestz = currz+setz
- end
- function setAreaGlobal()
- clearArea()
- local data = {}
- data[0] = "setArea"
- data[1] = currx+setx
- data[2] = curry+sety
- data[3] = currz+setz
- data[4] = currx+setx2
- data[5] = curry+sety2
- data[6] = currz+setz2
- data[7] = areaType
- sendMessage(textutils.serialize(data))
- end
- function showAreaToggle()
- areaShown = not areaShown
- showArea(areaShown)
- end
- function changeX(change)
- setx = setx + change
- if moveMode == "Move" then
- setx2 = setx2 + change
- elseif moveMode == "Expand" then
- setx2 = setx2 - change
- end
- end
- function changeY(change)
- sety = sety+change
- if moveMode == "Move" then
- sety2 = sety2 + change
- elseif moveMode == "Expand" then
- sety2 = sety2 - change
- end
- end
- function changeZ(change)
- setz = setz+change
- if moveMode == "Move" then
- setz2 = setz2 + change
- elseif moveMode == "Expand" then
- setz2 = setz2 - change
- end
- end
- function changeX2(change)
- setx2 = setx2 + change
- end
- function changeY2(change)
- sety2 = sety2+change
- end
- function changeZ2(change)
- setz2 = setz2+change
- end
- function gpsLocate()
- local x,y,z = gps.locate()
- return math.floor(x)-1, math.floor(y), math.floor(z)
- end
- function comeHere()
- local data = {}
- local x,y,z = gpsLocate()
- data[0] = "goto"
- data[1] = x
- data[2] = y
- data[3] = z
- sendMessage(textutils.serialize(data))
- end
- function setSpot(x,y,z)
- clearArea()
- local data = {}
- data[0] = "setSpot"
- data[1] = x
- data[2] = y
- data[3] = z
- sendMessage(textutils.serialize(data))
- end
- function setArea(x1,y1,z1,x2,y2,z2)
- clearArea()
- local data = {}
- data[0] = "setArea"
- data[1] = x1
- data[2] = y1
- data[3] = z1
- data[4] = x2
- data[5] = y2
- data[6] = z2
- sendMessage(textutils.serialize(data))
- end
- function hasItem(itemName)
- local data = {}
- data[0] = "hasItem"
- data[1] = itemName
- sendMessage(textutils.serialize(data))
- local id, message, distance, protocol = rednet.receive(5)
- return(message)
- end
- function inventoryImport(itemName)
- local data = {}
- data[0] = "inventoryImport"
- data[1] = itemName
- sendMessage(textutils.serialize(data))
- end
- function inventoryExport(itemName)
- local data = {}
- data[0] = "inventoryExport"
- data[1] = itemName
- sendMessage(textutils.serialize(data))
- end
- function showArea(show)
- local data = {}
- data[0] = "showArea"
- data[1] = show
- sendMessage(textutils.serialize(data))
- end
- function clearArea()
- local data = {}
- data[0] = "clearArea"
- sendMessage(textutils.serialize(data))
- areaShown = false
- showArea(areaShown)
- end
- function pickup()
- local data = {}
- data[0] = "pickup"
- sendMessage(textutils.serialize(data))
- end
- function dig()
- local data = {}
- data[0] = "dig"
- sendMessage(textutils.serialize(data))
- end
- function place()
- local data = {}
- data[0] = "place"
- sendMessage(textutils.serialize(data))
- end
- function attack()
- local data = {}
- data[0] = "attack"
- sendMessage(textutils.serialize(data))
- end
- function isDone()
- local data = {}
- data[0] = "isDone"
- sendMessage(textutils.serialize(data))
- local id, message, distance, protocol = rednet.receive(5)
- return(message)
- end
- function waitDone()
- while not isDone() do
- sleep(1)
- end
- end
- function hasPickaxe()
- return(hasItem("minecraft:diamond_pickaxe"))
- end
- function getPickaxe()
- if chesty ~= 0 then
- setSpot(chestx, chesty, chestz)
- inventoryImport("minecraft:diamond_pickaxe")
- setAreaGlobal()
- else
- button.label(1,20,"No Chest Location Set.")
- sleep(1)
- end
- end
- function getItems()
- if chesty ~= 0 then
- setSpot(chestx, chesty, chestz)
- inventoryImport("")
- setAreaGlobal()
- else
- button.label(1,20,"No Chest Location Set.")
- sleep(1)
- end
- end
- function dropItems()
- if chesty ~= 0 then
- setSpot(chestx, chesty, chestz)
- inventoryExport("")
- setAreaGlobal()
- else
- button.label(1,20,"No Chest Location Set.")
- sleep(1)
- end
- end
- function tempShowArea()
- showArea(true)
- sleep(3)
- showArea(false)
- end
- function setRadius(xRad, zRad, yUp, yDown)
- local x,y,z = gpsLocate()
- x = x
- y = y
- print(x..y..z)
- setArea(x-xRad, y-yDown, z-zRad, x+xRad, y+yUp, z+zRad)
- tempShowArea()
- end
- function setXYZ()
- local x,y,z = gpsLocate()
- x = x
- y = y
- setArea(x-xRad, y-yDown, z-zRad, x+xRad, y+yUp, z+zRad)
- end
- function goHome()
- local data = {}
- data[0] = "goto"
- data[1] = homex
- data[2] = homey
- data[3] = homez
- sendMessage(textutils.serialize(data))
- end
- function goTo()
- local data = {}
- data[0] = "goto"
- data[1] = currx+setx
- data[2] = curry+sety
- data[3] = currz+setz
- sendMessage(textutils.serialize(data))
- end
- function displayScreen()
- if menuType == "mainMenu" then
- mainMenu()
- elseif menuType == "xyzMenu" then
- xyzMenu()
- elseif menuType == "statusMenu" then
- statusMenu()
- end
- local event, side, x, y
- event, side, x, y = os.pullEvent()
- while event ~= "mouse_click" do
- event, side, x, y = os.pullEvent()
- end
- button.checkxy(x,y)
- end
- while true do
- displayScreen()
- end
- --clearArea()
- --dropItems()
- --getPickaxe()
- --setRadius(3,3,1,2)
- --dig()
- --waitDone()
- --clearArea()
- --setRadius(5,5,2,3)
- --pickup()
- --waitDone()
- --dropItems()
- --comeHere()
Add Comment
Please, Sign In to add comment