Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --rednet.open("back")
- local Stopped = true
- local Fuel = 200
- local MaxFuel = 1000
- function PaintScreen()
- term.setBackgroundColor(colors.white)
- term.clear()
- paintutils.drawFilledBox(1,1, 26,20, colors.black)
- -- Fuel level
- term.setCursorPos(1,1)
- write("Fuel")
- paintutils.drawLine(1,2, 26,2, colors.gray)
- paintutils.drawLine(1,2, (Fuel/MaxFuel)*26,2, colors.green)
- --Up
- paintutils.drawPixel(12, 4, colors.green)
- term.setCursorPos(12,4)
- write("\24")
- --Turn Left
- paintutils.drawPixel(10, 6, colors.green)
- term.setCursorPos(10,6)
- write("\17")
- --Stop/Go
- if (Stopped) then
- paintutils.drawPixel(12, 6, colors.red)
- else
- paintutils.drawPixel(12, 6, colors.green)
- end
- term.setCursorPos(12,6)
- write("\7")
- -- Turn Right
- paintutils.drawPixel(14, 6, colors.green)
- term.setCursorPos(14,6)
- write("\16")
- -- Down
- paintutils.drawPixel(12, 8, colors.green)
- term.setCursorPos(12,8)
- write("\25")
- -- Down
- paintutils.drawLine(2,10, 7,10, colors.green)
- term.setCursorPos(2,10)
- write("Refuel")
- -- Inventory
- for ix=1,8,2 do
- for iy=1,8,2 do
- paintutils.drawPixel(18+ix, 11+iy, colors.yellow)
- end
- end
- end
- function CheckButton(x,y)
- -- Missing inventory buttons
- if (x == 12 and y == 4) then --Up
- rednet.broadcast("Up")
- elseif (x == 12 and y == 8) then --Down
- rednet.broadcast("Down")
- elseif (x == 10 and y == 6) then --Left
- rednet.broadcast("Left")
- elseif (x == 14 and y == 6) then --Right
- rednet.broadcast("Right")
- elseif (x == 12 and y == 6) then --Stop/Go
- if (Stopped == true) then
- rednet.broadcast("Go")
- Stopped = false
- else
- rednet.broadcast("Stop")
- Stopped = true
- end
- end
- end
- function GetData()
- --Fuel
- rednet.broadcast("GetFuel")
- local id, msg = rednet.receive()
- if (msg ~= nil) then
- Fuel = msg
- end
- --Max fuel
- rednet.broadcast("GetMaxFuel")
- id, msg = rednet.receive()
- if (msg ~= nil) then
- MaxFuel = msg
- end
- --Is Digging
- rednet.broadcast("IsDigging")
- id, msg = rednet.receive()
- if (msg ~= nil) then
- Stopped = not msg
- end
- end
- peripheral.find("modem", rednet.open)
- while(true) do
- --GetData()
- PaintScreen()
- local event, button, x, y = os.pullEvent("mouse_click")
- CheckButton(x,y)
- end
Advertisement
Add Comment
Please, Sign In to add comment