Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- radar = peripheral.wrap("bottom")
- on = {}
- function add(number)
- -- print("add: " .. number)
- local cur = redstone.getBundledOutput("right")
- if not colors.test(cur, number) then
- redstone.setBundledOutput("right", cur + number)
- end
- on["" .. number] = 5
- end
- function remove(number)
- local cur = redstone.getBundledOutput("right")
- if colors.test(cur, number) then
- redstone.setBundledOutput("right", cur - number)
- end
- end
- function within(value, first, second)
- return first <= value and value <= second
- end
- function check()
- for k, v in pairs(on) do
- -- print(k .. ": " .. v)
- if v == 0 then
- remove(tonumber(k))
- else
- on[k] = on[k] - 1
- end
- end
- end
- while true do
- players = radar.getPlayers()
- for index, player in pairs(players) do
- -- print(player.x)
- -- print(player.y)
- -- print(player.z)
- if within(player.x, -1, 0) and within(player.y, 4, 7) and player.z == 0 then
- add(1)
- end
- if within(player.x, -1, 0) and within(player.y, 15, 18) and player.z == 0 then
- add(2)
- end
- if within(player.x, -1, 0) and within(player.y, 26, 29) and player.z == 0 then
- add(4)
- end
- if within(player.x, -1, 0) and within(player.y, 37, 40) and player.z == 0 then
- add(8)
- end
- if within(player.x, -1, 0) and within(player.y, 48, 51) and player.z == 0 then
- add(16)
- end
- if within(player.x, -1, 0) and within(player.y, 59, 62) and player.z == 0 then
- add(64)
- end
- if within(player.x, -1, 0) and within(player.y, 70, 73) and player.z == 0 then
- add(128)
- end
- end
- os.sleep(0.1)
- check()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement