Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("/pilabs/apis/button.lua")
- local function draw()
- term.setBackgroundColour(colours.black)
- term.clear()
- term.setBackgroundColour(colours.green)
- term.setTextColour(colours.black)
- for i, object in ipairs(buttons) do
- button.draw(object)
- end
- term.setBackgroundColour(colours.black)
- term.setTextColour(colours.white)
- end
- local function click(x, y)
- for i, object in ipairs(buttons) do
- if button.inBounds(object, x, y) then
- if object.action then
- object.action()
- end
- end
- end
- end
- local function key(key)
- if key == 87 then
- turtle.forward()
- elseif key == 65 then
- turtle.turnLeft()
- elseif key == 83 then
- turtle.back()
- elseif key == 68 then
- turtle.turnRight()
- elseif key == 69 then
- turtle.down()
- elseif key == 81 then
- turtle.up()
- end
- end
- local function net(id, message)
- end
- local buttons = {
- button.new(2, 2, 4, 3, "UP",
- function()
- turtle.up()
- end
- ),
- button.new(7, 2, 4, 3, "FD",
- function()
- turtle.forward()
- end
- ),
- button.new(12, 2, 4, 3, "DN",
- function()
- turtle.down()
- end
- ),
- button.new(2, 6, 4, 3, "TL",
- function()
- turtle.turnLeft()
- end
- ),
- button.new(7, 6, 4, 3, "BK",
- function()
- turtle.back()
- end
- ),
- button.new(12, 6, 4, 3, "TR",
- function()
- turtle.turnRight()
- end
- ),
- button.new(2, 10, 4, 3, "SU",
- function()
- turtle.suckUp()
- end
- ),
- button.new(7, 10, 4, 3, "SF",
- function()
- turtle.suck()
- end
- ),
- button.new(12, 10, 4, 3, "SD",
- function()
- turtle.suckDown()
- end
- ),
- button.new(25, 2, 4, 3, "AU",
- function()
- end
- ),
- button.new(30, 2, 4, 3, "AF",
- function()
- end
- ),
- button.new(35, 2, 4, 3, "AD",
- function()
- end
- ),
- button.new(25, 6, 4, 3, "PU",
- function()
- end
- ),
- button.new(30, 6, 4, 3, "PF",
- function()
- end
- ),
- button.new(35, 6, 4, 3, "PD",
- function()
- end
- ),
- button.new(25, 10, 4, 3, "",
- function()
- end
- ),
- button.new(30, 10, 4, 3, "",
- function()
- end
- ),
- button.new(35, 10, 4, 3, "",
- function()
- end
- ),
- button.new(17, 2, 7, 3, "APPS",
- function()
- --shell.run("/pilabs/turtle/appmenu.lua")
- draw()
- end
- ),
- button.new(17, 6, 7, 3, "TOOLS"),
- button.new(17, 10, 7, 3, "EXTRA")
- }
- draw()
- while true do
- local event, n, x, y = os.pullEvent()
- if event == "mouse_click" and n == 1 then
- click(x,y)
- elseif event == "key" then
- key(n)
- elseif event == "rednet_message" then
- net(n,x)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment