Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --VARIABLES
- local version = "TURTLE INTERACTIONS 0.9.2 (MV)"
- local w,h = term.getSize()
- local select, turtleslot = 1, 1
- local running = true
- local a, b, c, d, e, f, z = 6,7,8,9,10,11,h-2
- turtle.select(turtleslot)
- --PRINT
- local function printCentered(str, ypos)
- term.setCursorPos(w/2 - #str/2, ypos)
- term.write(str)
- end
- local function printRight(str, ypos)
- term.setCursorPos(w-#str, ypos)
- term.write(str)
- end
- function clearScreen()
- term.clear()
- term.setCursorPos(1,1)
- term.clear()
- end
- function drawHeader(title, line)
- printCentered(title, line)
- printCentered(string.rep("-", w), line+1)
- printRight("Fuel: "..turtle.getFuelLevel(), line+2)
- term.setCursorPos(1, line+2)
- term.write("\""..os.getComputerLabel().."\"")
- end
- function drawCopyright()
- printRight("by UNOBTANIUM", h)
- end
- -- MENUS
- function drawMenuTurtleInteractions()
- drawHeader(version, 1)
- drawCopyright()
- if select == 1 then
- printCentered("> Movement <", a)
- else
- printCentered("Movement", a)
- end
- if select == 2 then
- printCentered("> Actions <", b)
- else
- printCentered("Actions", b)
- end
- if select == 3 then
- printCentered("> Control <", c)
- else
- printCentered("Control", c)
- end
- if select == 4 then
- printCentered("> Update <", d)
- else
- printCentered("Update", d)
- end
- if select == 5 then
- printCentered("> Exit <", z)
- else
- printCentered("Exit", z)
- end
- end
- function drawMenuTurtleMovement()
- drawHeader(version, 1)
- drawHeader("TURTLE MOVEMENT", 3)
- if select == 1 then
- printCentered("> Forward <", a)
- else
- printCentered("Forward", a)
- end
- if select == 2 then
- printCentered("> Back <", b)
- else
- printCentered("Back", b)
- end
- if select == 3 then
- printCentered("> Up <", c)
- else
- printCentered("Up", c)
- end
- if select == 4 then
- printCentered("> Down <", d)
- else
- printCentered("Down", d)
- end
- if select == 5 then
- printCentered("> Turn Left <", e)
- else
- printCentered("Turn Left", e)
- end
- if select == 6 then
- printCentered("> Turn Right <", f)
- else
- printCentered("Turn Right", f)
- end
- if select == 7 then
- printCentered("> Back <", 12)
- else
- printCentered("Back", 12)
- end
- end
- function drawMenuTurtleActions()
- drawHeader(version, 1)
- drawHeader("TURTLE ACTIONS", 3)
- if select == 1 then
- printCentered("> Refuel <", a)
- else
- printCentered("Refuel", a)
- end
- if select == 2 then
- printCentered("> Dig <", b)
- else
- printCentered("Dig", b)
- end
- if select == 3 then
- printCentered("> Select <", c)
- else
- printCentered("Select", c)
- end
- if select == 4 then
- printCentered("> Back <", z)
- else
- printCentered("Back", z)
- end
- end
- function drawMenuTurtleDig()
- drawHeader(version, 1)
- drawHeader("TURTLE DIG", 3)
- if select == 1 then
- printCentered("> Up <", a)
- else
- printCentered("Up", a)
- end
- if select == 2 then
- printCentered("> Front <", b)
- else
- printCentered("Front", b)
- end
- if select == 3 then
- printCentered("> Down <", c)
- else
- printCentered("Down", c)
- end
- if select == 4 then
- printCentered("> Back <", z)
- else
- printCentered("Back", z)
- end
- end
- -- MENUSTATE
- local menustate = "turtleinteractions"
- local mopt = {
- ["turtleinteractions"] = {
- options = {"turtlemovement", "turtleactions", "control", "update", "quit"},
- draw = drawMenuTurtleInteractions
- },
- ["turtlemovement"] = {
- options = {"forward", "back", "up", "down", "left", "right" , "turtleinteractions"},
- draw = drawMenuTurtleMovement
- },
- ["turtleactions"] = {
- options = {"refuel", "turtledig", "select", "turtleinteractions"},
- draw = drawMenuTurtleActions
- },
- ["turtledig"] = {
- options = {"digup", "digfront", "digdown", "turtleactions"},
- draw = drawMenuTurtleDig
- }
- }
- function runMenu()
- while true do
- clearScreen()
- mopt[menustate].draw()
- local id, key = os.pullEvent("key")
- if key == 200 then
- select = select-1
- end
- if key == 208 then
- select = select+1
- end
- if select == 0 then
- select = #mopt[menustate].options
- end
- if select > #mopt[menustate].options then
- select = 1
- end
- clearScreen()
- if key == 28 then
- if mopt[menustate].options[select] == "quit" then
- running = false
- break
- elseif mopt[menustate].options[select] == "control" then
- control()
- elseif mopt[menustate].options[select] == "forward" then
- turtle.forward()
- elseif mopt[menustate].options[select] == "back" then
- turtle.back()
- elseif mopt[menustate].options[select] == "up" then
- turtle.up()
- elseif mopt[menustate].options[select] == "down" then
- turtle.down()
- elseif mopt[menustate].options[select] == "left" then
- turtle.turnLeft()
- elseif mopt[menustate].options[select] == "right" then
- turtle.turnRight()
- elseif mopt[menustate].options[select] == "refuel" then
- turtle.refuel(1)
- elseif mopt[menustate].options[select] == "select" then
- turtleslot = turtleslot + 1
- if turtleslot > 16 then turtleslot = 1 end
- turtle.select(turtleslot)
- elseif mopt[menustate].options[select] == "digup" then
- turtle.digUp()
- elseif mopt[menustate].options[select] == "digfront" then
- turtle.dig()
- elseif mopt[menustate].options[select] == "digdown" then
- turtle.digDown()
- elseif mopt[menustate].options[select] == "update" then
- update()
- elseif true then
- menustate = mopt[menustate].options[select]
- select = 1
- end
- end
- end
- end
- function update()
- shell.run("delete", "startup")
- shell.run("pastebin", "get M3D3RLCZ startup")
- end
- function control()
- local blockslot = 1
- local mode = "move"
- local working = true
- turtle.select(blockslot)
- function info()
- clearScreen()
- print("Navigate with your keyboard.")
- print("W A S D -- Horizontal")
- print("Space/SHIFT -- Up/Down")
- print("E -- Switch Mode")
- print("Q -- Next Slot")
- print("Ctrl -- Exit Interface.")
- print("")
- print("Turtle Mode: " .. mode)
- end
- while working do
- info()
- local id, key = os.pullEvent("key")
- if key == 29 then
- working = false
- elseif key == 16 then
- blockslot = blockslot + 1
- if blockslot == 17 then
- blockslot = 1
- end
- turtle.select(blockslot)
- elseif key == 30 then
- turtle.turnLeft()
- elseif key == 31 then
- turtle.back()
- elseif key == 32 then
- turtle.turnRight()
- elseif mode == "move" then
- if key == 17 then
- turtle.forward()
- elseif key == 57 then
- turtle.up()
- elseif key == 42 then
- turtle.down()
- elseif key == 18 then
- mode = "dig"
- end
- elseif mode == "dig" then
- if key == 17 then
- turtle.dig()
- elseif key == 57 then
- turtle.digUp()
- elseif key == 42 then
- turtle.digDown()
- elseif key == 18 then
- mode = "place"
- end
- elseif mode == "place" then
- if key == 17 then
- turtle.place()
- elseif key == 57 then
- turtle.placeUp()
- elseif key == 42 then
- turtle.placeDown()
- elseif key == 18 then
- mode = "movedig"
- end
- elseif mode == "movedig" then
- if key == 17 then
- turtle.dig()
- turtle.forward()
- elseif key == 57 then
- turtle.digUp()
- turtle.up()
- elseif key == 42 then
- turtle.digDown()
- turtle.down()
- elseif key == 18 then
- mode = "move"
- end
- end
- end
- end
- while running do
- runMenu()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement