Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- function loop()
- page = "main"
- animate = true
- while true do
- screen(page)
- animate = false
- listen()
- if page == "main" then
- if event == "mouse_click" then
- if x >= 3 and x <= 12 then
- if y >= 3 and y <= 5 then
- flash("Onward", 3, 12, 3, 5, colors.lime, colors.red)
- elseif y >= 7 and y <= 9 then
- flash("Backward", 3, 12, 7, 9, colors.lime, colors.red)
- elseif y >= 11 and y <= 13 then
- flash("StrafeLT", 3, 12, 11, 13, colors.lime, colors.red)
- elseif y == 15 then
- flash("Attack", 3, 12, 15, 15, colors.lime, colors.red)
- elseif y == 17 then
- flash("Detect", 3, 12, 17, 17, colors.lime, colors.red)
- elseif y == 19 then
- flash("Info", 3, 12, 19, 19, colors.lime, colors.red)
- end
- elseif x >= 15 and x <= 24 then
- if y >= 3 and y <= 5 then
- flash("GoUp", 15, 24, 3, 5, colors.lime, colors.red)
- elseif y >= 7 and y <= 9 then
- flash("GoDown", 15, 24, 7, 9, colors.lime, colors.red)
- elseif y >= 11 and y <= 13 then
- flash("StrafeRT", 15, 24, 11, 13, colors.lime, colors.red)
- elseif y == 15 then
- elseif y == 17 then
- elseif y == 19 then
- end
- end
- elseif event == "key" then
- if keyID == 17 then
- flash("Onward", 3, 12, 3, 5, colors.lime, colors.red)
- elseif keyID == 203 then
- flash("StrafeLT", 3, 12, 11, 13, colors.lime, colors.red)
- elseif keyID == 31 then
- flash("Backward", 3, 12, 7, 9, colors.lime, colors.red)
- elseif keyID == 205 then
- flash("StrafeRT", 15, 24, 11, 13, colors.lime, colors.red)
- elseif keyID == 208 then
- flash("GoDown", 15, 24, 7, 9, colors.lime, colors.red)
- elseif keyID == 200 then
- flash("GoUp", 15, 24, 3, 5, colors.lime, colors.red)
- elseif keyID == 30 then
- flash("Attack", 3, 12, 15, 15, colors.lime, colors.red)
- elseif keyID == 32 then
- flash("Detect", 3, 12, 17, 17, colors.lime, colors.red)
- elseif keyID == 23 then
- flash("Info", 3, 12, 19, 19, colors.lime, colors.red)
- end
- end
- end
- end
- end
- function getCoords()
- id, cX = rednet.receive()
- id, cY = rednet.receive()
- id, cZ = rednet.receive()
- if not cX or not cY or not cZ then
- tX = math.ceil((width-6)/2)
- term.setCursorPos(tX, 25)
- term.write("failed")
- else
- str = "(x, y, z): "..cX..", "..cY..", "..cZ
- tX = math.ceil((width-#str)/2)
- term.setCursorPos(tX, 25)
- term.write(str)
- end
- end
- function screen(page)
- rect("Turtle OS V1.0", 1, 26, 1, 1, colors.black)
- if page == "main" then
- --rect("12345678", 3, 12, 11, 13, colors.red)
- rect("Onward", 3, 12, 3, 5, colors.red)
- rect("GoUp", 15, 24, 3, 5, colors.red)
- rect("Backward", 3, 12, 7, 9, colors.red)
- rect("GoDown", 15, 24, 7, 9, colors.red)
- rect("StrafeLT", 3, 12, 11, 13, colors.red)
- rect("StrafeRT", 15, 24, 11, 13, colors.red)
- rect("Attack", 3, 12, 15, 15, colors.red)
- rect("Detect", 3, 12, 17, 17, colors.red)
- rect("PlaceBlock", 15, 24, 15, 15, colors.red)
- rect("Locate", 15, 24, 17, 17, colors.red)
- rect("Info", 3, 12, 19, 19, colors.red)
- rect("System", 15, 24, 19, 19, colors.red)
- end
- end
- function rect(label, xA, xB, yA, yB, col)
- pC = term.getBackgroundColor()
- term.setBackgroundColor(col)
- for x = xA, xB do
- for y = yA, yB do
- term.setCursorPos(x, y)
- term.write(" ")
- if animate == true then
- sleep(0.0001)
- end
- end
- end
- lX = math.ceil((xA+xB-#label)/2)
- lY = math.ceil((yA+yB)/2)
- term.setCursorPos(lX, lY)
- term.write(label)
- end
- function flash(label, xA, xB, yA, yB, fC, bC)
- rect(label, xA, xB, yA, yB, fC)
- sleep(0.15)
- rect(label, xA, xB, yA, yB, bC)
- end
- function listen()
- event, keyID, x, y = os.pullEvent()
- end
- function send(msg)
- rednet.send(turtleID, msg)
- end
- rednet.open("back")
- turtleID = 5
- loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement