SHOW:
|
|
- or go back to the newest paste.
| 1 | rednet.open("back")
| |
| 2 | if fs.exists("id") then
| |
| 3 | file = fs.open("id", "r")
| |
| 4 | robitid = tonumber(file.readLine()) | |
| 5 | file.close() | |
| 6 | else | |
| 7 | robitid = 1 | |
| 8 | end | |
| 9 | ||
| 10 | side = 2 | |
| 11 | ||
| 12 | - | rednet.broadcast("forward",robitid)
|
| 12 | + | term.clear() |
| 13 | x = 13 | |
| 14 | y = 18 | |
| 15 | ||
| 16 | while true do | |
| 17 | local event, character = os.pullEvent("char")
| |
| 18 | if character == "w" then | |
| 19 | rednet.broadcast("forward",robitid)
| |
| 20 | - | if character == "s" then |
| 20 | + | senderIdf, messagef, protocolf = rednet.receive(2) |
| 21 | - | rednet.broadcast("back",robitid)
|
| 21 | + | if messagef == "true" then |
| 22 | if side == 0 then | |
| 23 | paintutils.drawPixel(x,y,colors.orange) | |
| 24 | y = y+1 | |
| 25 | paintutils.drawPixel(x,y,colors.green) | |
| 26 | elseif side == 1 then | |
| 27 | paintutils.drawPixel(x,y,colors.orange) | |
| 28 | x = x-1 | |
| 29 | paintutils.drawPixel(x,y,colors.green) | |
| 30 | elseif side == 2 then | |
| 31 | paintutils.drawPixel(x,y,colors.orange) | |
| 32 | y = y-1 | |
| 33 | paintutils.drawPixel(x,y,colors.green) | |
| 34 | elseif side == 3 then | |
| 35 | paintutils.drawPixel(x,y,colors.orange) | |
| 36 | x = x+1 | |
| 37 | paintutils.drawPixel(x,y,colors.green) | |
| 38 | end | |
| 39 | else | |
| 40 | if side == 0 then | |
| 41 | paintutils.drawPixel(x,y+1,colors.red) | |
| 42 | elseif side == 1 then | |
| 43 | paintutils.drawPixel(x-1,y,colors.red) | |
| 44 | elseif side == 2 then | |
| 45 | paintutils.drawPixel(x,y-1,colors.red) | |
| 46 | elseif side == 3 then | |
| 47 | paintutils.drawPixel(x+1,y,colors.red) | |
| 48 | end | |
| 49 | end | |
| 50 | end | |
| 51 | if character == "a" then | |
| 52 | rednet.broadcast("left",robitid)
| |
| 53 | side = side - 1 | |
| 54 | if side < 0 then | |
| 55 | side = 3 | |
| 56 | end | |
| 57 | if side == 0 then | |
| 58 | term.setCursorPos(1,1) | |
| 59 | term.write(' v')
| |
| 60 | elseif side == 1 then | |
| 61 | term.setCursorPos(1,1) | |
| 62 | term.write("<-")
| |
| 63 | elseif side == 2 then | |
| 64 | term.setCursorPos(1,1) | |
| 65 | term.write(' ^')
| |
| 66 | elseif side == 3 then | |
| 67 | term.setCursorPos(1,1) | |
| 68 | term.write("->")
| |
| 69 | end | |
| 70 | end | |
| 71 | if character == "d" then | |
| 72 | rednet.broadcast("right",robitid)
| |
| 73 | side = side + 1 | |
| 74 | if side > 3 then | |
| 75 | side = 0 | |
| 76 | end | |
| 77 | if side == 0 then | |
| 78 | term.setCursorPos(1,1) | |
| 79 | term.write(' v')
| |
| 80 | elseif side == 1 then | |
| 81 | term.setCursorPos(1,1) | |
| 82 | term.write("<-")
| |
| 83 | elseif side == 2 then | |
| 84 | term.setCursorPos(1,1) | |
| 85 | term.write(' ^')
| |
| 86 | elseif side == 3 then | |
| 87 | term.setCursorPos(1,1) | |
| 88 | term.write("->")
| |
| 89 | end | |
| 90 | end | |
| 91 | if character == "q" then | |
| 92 | rednet.broadcast("up",robitid)
| |
| 93 | end | |
| 94 | if character == "e" then | |
| 95 | rednet.broadcast("down",robitid)
| |
| 96 | end | |
| 97 | if character == "r" then | |
| 98 | rednet.broadcast("dig",robitid)
| |
| 99 | end | |
| 100 | if character == "p" then | |
| 101 | rednet.broadcast("place",robitid)
| |
| 102 | end | |
| 103 | if character == "f" then | |
| 104 | rednet.broadcast("fight",robitid)
| |
| 105 | end | |
| 106 | if character == "u" then | |
| 107 | rednet.broadcast("placeu",robitid)
| |
| 108 | end | |
| 109 | if character == "j" then | |
| 110 | rednet.broadcast("placed",robitid)
| |
| 111 | end | |
| 112 | if character == "c" then | |
| 113 | rednet.broadcast("mineu",robitid)
| |
| 114 | end | |
| 115 | if character == "z" then | |
| 116 | rednet.broadcast("mined",robitid)
| |
| 117 | end | |
| 118 | if character == "x" then | |
| 119 | rednet.broadcast("close",robitid)
| |
| 120 | end | |
| 121 | if character == "i" then | |
| 122 | term.clear() | |
| 123 | term.setCursorPos(1,1) | |
| 124 | term.write("robit id:")
| |
| 125 | robitid = read() | |
| 126 | file = fs.open("id", "w")
| |
| 127 | file.writeLine(robitid) | |
| 128 | file.close() | |
| 129 | end | |
| 130 | end |