Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- os.loadAPI("button")
- local droneControlID = 2
- local m = term
- local areaShown = false
- 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 importChest = {}
- importChest["x"] = 0
- importChest["y"] = 0
- importChest["z"] = 0
- local exportChest = {}
- exportChest["x"] = 0
- exportChest["y"] = 0
- exportChest["z"] = 0
- local home = {}
- home["x"] = 0
- home["y"] = 0
- home["z"] = 0
- --local homex = 0
- --local homey = 0
- --local homez = 0
- --local chestx = 0
- --local chesty = 0
- --local chestz = 0
- local menuType = "mainMenu"
- local areaType = "Filled"
- local moveMode = "Normal"
- local teleportMode = false
- local autoApply = true
- function sendMessage(message)
- rednet.send(droneControlID, 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("Build", place, "", 15, 25, 5, 5)
- button.setTable("ItemPickup", pickup, "", 3, 13, 7, 7)
- button.setTable("Attack", attack, "", 15,25,7,7)
- button.setTable("Ent Pickup", entityPickup, "", 3, 13, 9, 9)
- button.setTable("Ent Drop", entityDrop, "", 15, 25, 9, 9)
- button.setTable("GetItems", getItems, "", 3, 13, 11,11)
- button.setTable("Get Pick", getPickaxe, "", 15, 25, 11, 11)
- button.setTable("ItemsChest", dropItems, "", 3, 13, 13, 13)
- button.setTable("Stop", stopAction, "", 3, 13, 16, 16)
- button.setTable("Teleport", toggleTeleport, "", 15, 25, 16, 16)
- button.setTable("Favorites", setFavoritesMenu, "", 3, 13, 18, 18)
- -- button.setTable("Set Home", setHome, "", 15, 25, 18, 18)
- button.setTable("Show Area", showAreaToggle, "", 15, 25, 20, 20)
- button.setTable("Status", setStatusMenu, "", 3, 13, 20, 20)
- if teleportMode then
- button.toggleButton("Teleport")
- 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,"Last Act: "..getAction())
- button.label(1,7,"Home: "..home["x"]..", "..home["y"]..", "..home["z"])
- button.label(1,8,"Imp Chest "..importChest["x"]..", "..importChest["y"]..", "..importChest["z"])
- button.label(1,9,"Exp Chest "..exportChest["x"]..", "..exportChest["y"]..", "..exportChest["z"])
- button.label(1,10,"LSet: "..(currx+setx)..", "..(curry+sety)..", "..(currz+setz))
- button.label(1,11,"LSet2: "..(currx+setx2)..", "..(curry+sety2)..", "..(currz+setz2))
- -- button.setTable("ShowHome", showHome, "", 3,13,18,18)
- -- button.setTable("ShowImportChest", showImportChest, "", 15, 25, 18,18)
- -- button.label(1,6,"Pickaxe: "..tostring(hasPickaxe()))
- button.screen()
- end
- function favoritesMenu()
- m.clear()
- button.clearTable()
- button.setTable("Back", setMainMenu, "", 1, 6, 1, 1)
- button.label(1,2, "Show Favorites")
- button.setTable("Home.", showHome, "", 3,13,3,3)
- button.label(1,4, "Chests")
- button.setTable("Import.", showImportChest, "", 3, 13, 5,5)
- button.setTable("Export.", showExportChest, "", 15, 25, 5,5)
- button.label(1,15,"Set Favorites")
- button.setTable("Home", setHome, "", 3, 13, 16, 16)
- button.label(3,17,"Chests")
- button.setTable("Import", setImportChest, "", 3, 13, 18, 18)
- button.setTable("Export", setExportChest, "", 15, 25, 18, 18)
- 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("Auto Apply", setAutoApply, "", 3, 13, 20, 20)
- button.setTable("Apply", refreshArea, "", 15, 25, 20, 20)
- button.setButton("Show Area", areaShown)
- button.setButton("Auto Apply", autoApply)
- button.screen()
- end
- function getAction()
- local data = {}
- data[0] = "getAction"
- sendMessage(textutils.serialize(data))
- local id, message, distance, protocol = rednet.receive(5)
- if message then
- return(message)
- else
- return("Nothing")
- end
- end
- function showHome()
- button.toggleButton("Home.")
- setArea(home["x"], home["y"], home["z"], home["x"], home["y"], home["z"], "Filled")
- showArea(true)
- sleep(2)
- button.toggleButton("Home.")
- refreshArea()
- end
- function showImportChest()
- button.toggleButton("Import.")
- setArea(importChest["x"], importChest["y"]-1, importChest["z"], importChest["x"], importChest["y"]+1, importChest["z"], "Filled")
- showArea(true)
- sleep(2)
- button.toggleButton("Import.")
- refreshArea()
- end
- function showExportChest()
- button.toggleButton("Export.")
- setArea(exportChest["x"], exportChest["y"]-1, exportChest["z"], exportChest["x"], exportChest["y"]+1, exportChest["z"], "Filled")
- showArea(true)
- sleep(2)
- button.toggleButton("Export.")
- refreshArea()
- end
- function setAutoApply()
- autoApply = not autoApply
- end
- function toggleMoveMode()
- if moveMode == "Normal" then
- moveMode = "Move"
- elseif moveMode == "Move" then
- moveMode = "Expand"
- elseif moveMode == "Expand" then
- moveMode = "Normal"
- end
- end
- function toggleTeleport()
- teleportMode = not teleportMode
- 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 setFavoritesMenu()
- menuType = "favoritesMenu"
- end
- function refreshArea()
- setAreaGlobal()
- showArea(false)
- showArea(true)
- areaShown = true
- end
- function setImportChest()
- button.flash("Import")
- importChest["x"] = currx+setx
- importChest["y"] = curry+sety
- importChest["z"] = currz+setz
- writeImportChest()
- end
- function setExportChest()
- button.flash("Export")
- exportChest["x"] = currx+setx
- exportChest["y"] = curry+sety
- exportChest["z"] = currz+setz
- writeExportChest()
- end
- function setHome()
- button.flash("Home")
- home["x"] = currx+setx
- home["y"] = curry+sety
- home["z"] = currz+setz
- writeHome()
- end
- function writeHome()
- file = io.open("homeCoords", "w")
- file:write(textutils.serialize(home))
- file:close()
- end
- function readHome()
- file = io.open("homeCoords", "r")
- if file then
- home = textutils.unserialize(file:read("*a"))
- file:close()
- end
- end
- function writeImportChest()
- file = io.open("chestImportCoords", "w")
- file:write(textutils.serialize(importChest))
- file:close()
- end
- function readImportChest()
- file = io.open("chestImportCoords", "r")
- if file then
- importChest = textutils.unserialize(file:read("*a"))
- file:close()
- end
- end
- function writeExportChest()
- file = io.open("chestExportCoords", "w")
- file:write(textutils.serialize(exportChest))
- file:close()
- end
- function readExportChest()
- file = io.open("chestExportCoords", "r")
- if file then
- exportChest = textutils.unserialize(file:read("*a"))
- file:close()
- end
- 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
- if autoApply then
- refreshArea()
- end
- end
- function changeY(change)
- sety = sety+change
- if moveMode == "Move" then
- sety2 = sety2 + change
- elseif moveMode == "Expand" then
- sety2 = sety2 - change
- end
- if autoApply then
- refreshArea()
- end
- end
- function changeZ(change)
- setz = setz+change
- if moveMode == "Move" then
- setz2 = setz2 + change
- elseif moveMode == "Expand" then
- setz2 = setz2 - change
- end
- if autoApply then
- refreshArea()
- end
- end
- function changeX2(change)
- setx2 = setx2 + change
- if autoApply then
- refreshArea()
- end
- end
- function changeY2(change)
- sety2 = sety2+change
- if autoApply then
- refreshArea()
- end
- end
- function changeZ2(change)
- setz2 = setz2+change
- if autoApply then
- refreshArea()
- end
- end
- function gpsLocate()
- local x,y,z = gps.locate()
- return math.floor(x), math.floor(y), math.floor(z)
- end
- function comeHere()
- button.flash("Come Here")
- local data = {}
- local x,y,z = gpsLocate()
- if teleportMode then
- data[0] = "teleport"
- else
- data[0] = "goto"
- end
- data[1] = x
- data[2] = y
- data[3] = z
- sendMessage(textutils.serialize(data))
- setAreaGlobal()
- 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, areaType)
- clearArea()
- local data = {}
- data[0] = "setArea"
- data[1] = x1
- data[2] = y1
- data[3] = z1
- data[4] = x2
- data[5] = y2
- data[6] = z2
- data[7] = areaType
- 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()
- button.flash("ItemPickup")
- local data = {}
- data[0] = "pickup"
- sendMessage(textutils.serialize(data))
- end
- function dig()
- button.flash("Dig")
- local data = {}
- data[0] = "dig"
- sendMessage(textutils.serialize(data))
- end
- function entityPickup()
- button.flash("Ent Pickup")
- local data = {}
- data[0] = "entityImport"
- sendMessage(textutils.serialize(data))
- end
- function stopAction()
- button.flash("Stop")
- local data = {}
- data[0] = "exitPiece"
- sendMessage(textutils.serialize(data))
- end
- function entityDrop()
- button.flash("Ent Drop")
- local data = {}
- data[0] = "entityExport"
- sendMessage(textutils.serialize(data))
- end
- function place()
- button.flash("Build")
- local data = {}
- data[0] = "place"
- 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 attack()
- button.flash("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()
- button.flash("Get Pick")
- if importChest["y"] ~= 0 then
- setSpot(importChest["x"], importChest["y"], importChest["z"])
- inventoryImport("minecraft:diamond_pickaxe")
- setAreaGlobal()
- else
- button.label(1,20,"No importChest Location Set.")
- sleep(1)
- end
- end
- function getItems()
- button.flash("GetItems")
- if importChest["y"] ~= 0 then
- setSpot(importChest["x"], importChest["y"], importChest["z"])
- inventoryImport("")
- setAreaGlobal()
- else
- button.label(1,20,"No importChest Location Set.")
- sleep(1)
- end
- end
- function dropItems()
- button.flash("ItemsChest")
- if importChest["y"] ~= 0 then
- setSpot(exportChest["x"], exportChest["y"], exportChest["z"])
- inventoryExport("")
- setAreaGlobal()
- else
- button.label(1,20,"No exportChest 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 = {}
- button.flash("Go Home")
- if teleportMode then
- data[0] = "teleport"
- else
- data[0] = "goto"
- end
- data[1] = home["x"]
- data[2] = home["y"]
- data[3] = home["z"]
- sendMessage(textutils.serialize(data))
- setAreaGlobal()
- end
- function goTo()
- button.flash("GoTo")
- local data = {}
- if teleportMode then
- data[0] = "teleport"
- else
- data[0] = "goto"
- end
- data[1] = currx+setx
- data[2] = curry+sety
- data[3] = currz+setz
- sendMessage(textutils.serialize(data))
- end
- function teleport()
- local data = {}
- data[0] = "teleport"
- 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()
- elseif menuType == "favoritesMenu" then
- favoritesMenu()
- 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
- readHome()
- readImportChest()
- readExportChest()
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement