SHOW:
|
|
- or go back to the newest paste.
| 1 | rednet.open("back")
| |
| 2 | robitids = {}
| |
| 3 | robitid = 329 | |
| 4 | - | robitid = tonumber(file.readLine()) |
| 4 | + | robitalue = 1 |
| 5 | if fs.exists("id") then
| |
| 6 | file = fs.open("id", "r")
| |
| 7 | - | robitid = 1 |
| 7 | + | for i=1, 4 do |
| 8 | robitids[i] = file.readLine() | |
| 9 | end | |
| 10 | file.close() | |
| 11 | else | |
| 12 | robitids = {329, 330, 331, 1}
| |
| 13 | end | |
| 14 | ||
| 15 | ||
| 16 | ||
| 17 | ||
| 18 | while true do | |
| 19 | ||
| 20 | - | if character == "s" then |
| 20 | + | term.clear() |
| 21 | - | rednet.broadcast("back",robitid)
|
| 21 | + | |
| 22 | term.write("your turn, id:"..robitalue)
| |
| 23 | - | if character == "q" then |
| 23 | + | term.setCursorPos(1,2) |
| 24 | - | rednet.broadcast("up",robitid)
|
| 24 | + | term.write("1-4 to change robit")
|
| 25 | ||
| 26 | - | if character == "e" then |
| 26 | + | choose = true |
| 27 | - | rednet.broadcast("down",robitid)
|
| 27 | + | while choose do |
| 28 | ||
| 29 | - | if character == "r" then |
| 29 | + | term.clear() |
| 30 | term.setCursorPos(1,1) | |
| 31 | term.write("your turn, id:"..robitalue)
| |
| 32 | term.setCursorPos(1,2) | |
| 33 | term.write("1-4 to change robit")
| |
| 34 | local event, character = os.pullEvent("char")
| |
| 35 | - | if character == "f" then |
| 35 | + | |
| 36 | - | rednet.broadcast("fight",robitid)
|
| 36 | + | if character == "1" then |
| 37 | robitid = robitids[1] | |
| 38 | - | if character == "u" then |
| 38 | + | robitalue = 1 |
| 39 | - | rednet.broadcast("placeu",robitid)
|
| 39 | + | |
| 40 | if character == "2" then | |
| 41 | - | if character == "j" then |
| 41 | + | robitid = robitids[2] |
| 42 | - | rednet.broadcast("placed",robitid)
|
| 42 | + | robitalue = 2 |
| 43 | end | |
| 44 | - | if character == "c" then |
| 44 | + | if character == "3" then |
| 45 | - | rednet.broadcast("mineu",robitid)
|
| 45 | + | robitid = robitids[3] |
| 46 | robitalue = 3 | |
| 47 | - | if character == "z" then |
| 47 | + | |
| 48 | - | rednet.broadcast("mined",robitid)
|
| 48 | + | if character == "4" then |
| 49 | robitid = robitids[4] | |
| 50 | - | if character == "x" then |
| 50 | + | robitalue = 4 |
| 51 | - | rednet.broadcast("close",robitid)
|
| 51 | + | |
| 52 | if character == "w" then | |
| 53 | rednet.broadcast("dig",robitid)
| |
| 54 | os.sleep(0.1) | |
| 55 | rednet.broadcast("forward",robitid)
| |
| 56 | - | term.write("robit id:")
|
| 56 | + | senderIdf, messagef, protocolf = rednet.receive(2) |
| 57 | - | robitid = read() |
| 57 | + | if messagef == "true" then |
| 58 | choose = false | |
| 59 | end | |
| 60 | end | |
| 61 | if character == "a" then | |
| 62 | rednet.broadcast("left",robitid)
| |
| 63 | end | |
| 64 | if character == "d" then | |
| 65 | rednet.broadcast("right",robitid)
| |
| 66 | end | |
| 67 | if character == "p" then | |
| 68 | rednet.broadcast("place",robitid)
| |
| 69 | end | |
| 70 | if character == "i" then | |
| 71 | term.clear() | |
| 72 | term.setCursorPos(1,1) | |
| 73 | file = fs.open("id", "w")
| |
| 74 | for i=1,4 do | |
| 75 | term.write("robit id "..i..":")
| |
| 76 | robitids[i] = read() | |
| 77 | file.writeLine(robitid) | |
| 78 | end | |
| 79 | file.close() | |
| 80 | end | |
| 81 | end | |
| 82 | rednet.broadcast("turn", "turn")
| |
| 83 | ||
| 84 | term.clear() | |
| 85 | term.setCursorPos(1,1) | |
| 86 | term.write("opponent's turn")
| |
| 87 | ||
| 88 | senderId, message, protocol = rednet.receive("turn")
| |
| 89 | end |