Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x,y = term.getSize()
- running = true
- routine = {}
- --[[
- W forward
- A left
- S back
- D right
- Q up
- Z down
- R dig up
- F dig
- C dig down
- T place up
- G place
- V place down
- [ select left slot (navigation)
- ] select right slot (navigation)
- X execute
- --]]
- function drawGUI()
- term.clear()
- for i = 1,y do
- term.setCursorPos(1,i)
- if i == 1 then
- fuel=
- print("Fuel: "..turtle.getFuelLevel().." Xylem's TController")
- elseif i == 2 then
- for i = 1,x do
- term.write("_")
- end
- elseif i == y-2 then
- for i = 1,x do
- term.write("_")
- end
- elseif i == y then
- term.write("> ")
- end
- end
- end
- function appendRoutine(object,state)
- if routine == nil and state == nil then
- routine = {}
- routine[1] = object
- elseif routine~= nil and state == nil then
- index = table.getn(routine) + 1
- routine[index] = object
- elseif object == nil and state == "remove" then
- index2 = table.getn(routine)
- routine[index2] = nil
- end
- for i = 1,y do
- term.setCursorPos(1,i)
- if i > 2 and i < y-2 then
- term.clearLine()
- end
- end
- term.setCursorPos(1,3)
- cx,cy = term.getCursorPos()
- temp = 3
- temp2 = 0
- for i in ipairs(routine) do
- if temp2 <= x-3 then
- term.write(routine[i]..",")
- temp2 = temp2+3
- else
- temp = temp+1
- temp2 = 0
- term.setCursorPos(1,temp)
- term.write(routine[i]..",")
- end
- end
- end
- drawGUI()
- function run()
- number = table.getn(routine)
- if number <= 0 then
- term.setCursorPos(1,3)
- term.setTextColour(colours.red)
- print("Nothing to execute")
- term.setTextColour(colours.white)
- sleep(2)
- term.setCursorPos(1,3)
- term.clearLine()
- elseif number > 0 then
- for i in ipairs(routine) do
- if routine[i] == "fw" then
- turtle.forward()
- elseif routine[i] == "lf" then
- turtle.turnLeft()
- elseif routine[i] == "bk" then
- turtle.backward()
- elseif routine[i] == "ri" then
- turtle.turnRight()
- elseif routine[i] == "up" then
- turtle.up()
- elseif routine[i] == "dw" then
- turtle.down()
- elseif routine[i] == "du" then
- turtle.digUp()
- elseif routine[i] == "di" then
- turtle.dig()
- elseif routine[i] == "dd" then
- turtle.digDown()
- elseif routine[i] == "pu" then
- turtle.placeUp()
- elseif routine[i] == "pl" then
- turtle.place()
- elseif routine[i] == "pd" then
- turtle.placeDown()
- end
- end
- end
- end
- while running do
- event, param1, param2 = os.pullEvent()
- term.setCursorPos(1,y)
- if event == "char" or event == "key" then
- term.clearLine()
- term.write("> "..event..": "..param1.." Credit to AngleMalus")
- end
- if event == "char" then
- if param1 == 'w' then -- w
- appendRoutine("fw")
- elseif param1 == 'a' then -- a
- appendRoutine("lf")
- elseif param1 == 's' then -- s
- appendRoutine("bk")
- elseif param1 == 'd' then -- d
- appendRoutine("ri")
- elseif param1 == 'q' then -- q
- appendRoutine("up")
- elseif param1 == 'z' then -- z
- appendRoutine("dw")
- elseif param1 == 'r' then -- r
- appendRoutine("du")
- elseif param1 == 'f' then -- f
- appendRoutine("di")
- elseif param1 == 'c' then -- c
- appendRoutine("dd")
- elseif param1 == 't' then -- t
- appendRoutine("pu")
- elseif param1 == 'g' then -- g
- appendRoutine("pl")
- elseif param1 == 'v' then -- v
- appendRoutine("pd")
- elseif param1 == 'x' then -- x
- run()
- elseif param1 == '[' then
- cpos = turtle.getSelectedSlot()
- if cpos >= 2 then
- turtle.select(cpos-1)
- end
- elseif param1 == ']' then
- cpos = turtle.getSelectedSlot()
- if cpos <= 15 then
- turtle.select(cpos+1)
- end
- end
- end
- if event == "key" then
- if param1 == 14 then -- backspace
- appendRoutine(nil,"remove")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement