Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.setBackgroundColor(colors.green)
- term.clear()
- if rs.getInput("right") then
- returnPad = true
- else
- returnPad = false
- end
- local com = peripheral.wrap("back")
- local com = {}
- com.setCommand = function(command) write(command) end
- com.runCommand = function() write("Running command") end
- --os.pullEvent = os.pullEventRaw
- local x, y = term.getSize()
- local menu = returnPad and {
- {title = "Observation area",
- comList = {
- "/clear @p 402",
- "/manuadd @p default",
- "/tp @p " --return teleport
- },
- x1 = 3,
- x2 = 18,
- y = 9
- }
- }
- or
- {
- {title = "Turtle Free Play",
- comList = {
- "/give @p 402:258 1",
- "/gamemode a @p",
- "/manuadd @p turtle",
- "/tp @p -296 26 160"
- },
- x1 = 3,
- x2 = 18,
- y = 8
- },
- {title = "Rednet Practice",
- comList = {
- "/give @p 402:258 1",
- "/gamemode a @p",
- "/manuadd @p turtle",
- "/tp @p -296 26 160"
- },
- x1 = 3,
- x2 = 17,
- y = 9
- },
- {title = "Turtle Navigation",
- comList = {
- "/give @p 402:258 1",
- "/gamemode a @p",
- "/manuadd @p turtle",
- "/tp @p -296 26 160"
- },
- x1 = 3,
- x2 = 19,
- y = 10
- },
- {title = "Redstone Practice",
- comList = {
- "/give @p 402:258 1",
- "/gamemode a @p",
- "/manuadd @p turtle",
- "/tp @p -296 26 160"
- },
- x1 = 3,
- x2 = 19,
- y = 11
- }
- }
- local function gui(scroll, side)
- for i = 1, y do
- term.setBackgroundColor(colors.red)
- term.setCursorPos(1, i)
- write(" ")
- term.setCursorPos(x, i)
- write(" ")
- term.setCursorPos(1, 1)
- write(string.rep(" ", x))
- term.setCursorPos(1, y)
- write(string.rep(" ", x))
- end
- for i= 1, #menu do
- term.setCursorPos(menu[i].x1, menu[i].y)
- term.setBackgroundColor(colors.green)
- write(menu[i].title)
- end
- term.setCursorPos(3, scroll + 7)
- term.setBackgroundColor(colors.lightBlue)
- write(menu[scroll].title)
- local turtleImage = paintutils.loadImage("turtle"..side..".nfa")
- paintutils.drawImage(turtleImage, 21, 2)
- end
- local scroll = 1
- local side = 1
- gui(scroll, side)
- local sideTimer = nil
- while true do
- if not sideTimer then
- sideTimer = os.startTimer(1)
- end
- local events = {os.pullEvent()}
- if events[1] == "mouse_click" and events[2] == 1 then
- for i = 1, #menu do
- if events[4] == menu[i].y then
- scroll = menu[i].y - 7
- for i = 1, #menu[scroll].comList do
- sleep(.05)
- com.setCommand(menu[scroll].comList[i])
- com.runCommand()
- end
- break
- end
- end
- sideTimer = nil
- elseif events[1] == "mouse_scroll" then
- if events[2] == 1 then
- scroll = scroll + 1
- elseif events[2] == -1 then
- scroll = scroll - 1
- end
- elseif events[1] == "timer" and events[2] == sideTimer then
- side = side + 1
- if side > 4 then side = 1 end
- sleep(0)
- sideTimer = nil
- elseif events[1] == "key" then
- if events[2] == 28 then
- for i = 1, #menu[scroll].comList do
- sleep(.05)
- com.setCommand(menu[scroll].comList[i])
- com.runCommand()
- end
- sideTimer = nil
- elseif events[2] == 200 then
- scroll = scroll - 1
- elseif events[2] == 208 then
- scroll = scroll + 1
- end
- end
- if scroll < 1 then scroll = 1 elseif scroll > #menu then scroll = #menu end
- gui(scroll, side)
- end
- sleep(0)
Advertisement
Add Comment
Please, Sign In to add comment