Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- radar = peripheral.wrap("bottom")
- chat = peripheral.wrap("right")
- modem = peripheral.wrap("top")
- modem.open(11)
- mapping = {}
- mapping[1] = "0 0 0 0 0 8 12 0 12 0 12 0 12"
- mapping[2] = "0 20 30 42 33 34 18 34 33 42 30 20 0"
- mapping[3] = "0 20 30 46 33 34 18 34 33 46 30 20 0"
- mapping[4] = "58 24 34 100 26 82 47 4 25 82 37 94 16"
- mapping[5] = "0 0 0 0 0 0 0 0 0 0 0 0"
- state = 1
- function set(num)
- modem.transmit(10,11, mapping[num])
- state = num
- end
- function build(num, value)
- result = ""
- for i = 1, 13 do
- result = result .. ((num == i and value) or "0")
- if i ~= 13 then
- result = result .. " "
- end
- end
- return result
- end
- function det(x, z)
- res = {}
- res["row"] = math.ceil((z - 20) / -7)
- res["col"] = math.ceil((x + 10) / 7)
- return res
- end
- function check(row1, col1, row2, col2)
- first = false
- second = false
- players = radar.getPlayers()
- for index, player in pairs(players) do
- pos = det(player.x, player.z)
- print(pos.row)
- print(pos.col)
- if pos.row == row1 and pos.col == col1 then
- first = true
- end
- if pos.row == row2 and pos.col == col2 then
- second = true
- end
- end
- return first and second
- end
- set(state)
- os.startTimer(2)
- while true do
- e, v1, v2, v3, v4 = os.pullEvent()
- if e == "timer" then
- if state == 1 and check(4,4,4,4) then
- set(2)
- elseif state == 2 and check(2, 3, 6, 3) then
- set(3)
- modem.transmit(15,11, "222")
- os.sleep(8)
- set(4)
- elseif state == 4 and check(4,5,5,5) then
- set(5)
- end
- os.startTimer(2)
- elseif e == "command" then
- if v2[1] == "set" then
- modem.transmit(10,11, build(tonumber(v2[2]), v2[3]))
- elseif v2[1] == "select" then
- modem.transmit(10,11, mapping[tonumber(v2[2])])
- elseif v2[1] == "tell" then
- print(check(1,1,1,1))
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement