Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- local sensor = sensor.wrap("left")
- local glass = peripheral.wrap("right")
- local wx, wy = -8.5, -8.5 -- world x/y
- local x, y = 5, 5
- local w, h = 60, 60
- local bw, bh = w/20, h/20 -- block w/h
- glass.clear()
- local grassbox = glass.addBox(x, y, w, h, 0x32C82D, 1)
- grassbox.setZIndex(0)
- local building = glass.addBox(x+(bw*3), y+(bh*3), w-(bw*6), h-(bh*6), 0x999999, 1)
- building.setZIndex(1)
- local z = 2
- local dont_add = {
- "Chicken%d+",
- "Cow%d+",
- "Sheep%d+",
- "Pig%d+",
- "Zombie%d+",
- "Skeleton%d+",
- "Spider%d+",
- "Creeper%d+",
- "Enderman%d+",
- "Bat%d+",
- "Witch%d+",
- }
- local players = {}
- while true do
- local targets = sensor.getTargets()
- for i, v in pairs(targets) do
- local add = true
- for k,l in pairs(dont_add) do
- if string.find(i, l) then
- add = false
- end
- end
- if add then
- if not players[i] then
- players[i] = {}
- print("Added player: "..i)
- end
- if not players[i].box then
- players[i].box = glass.addBox(0, 0, 4, 4, 0xFF0000, 1)
- players[i].box.setZIndex(z)
- players[i].text = glass.addText(0, 0, i, 0x000000)
- players[i].text.setZIndex(z+1)
- z = z + 2
- end
- players[i].box.setX((v.Position.X - wx - 2 + x)*bw)
- players[i].box.setY((v.Position.Z - wy - 2 + y)*bh)
- players[i].text.setX((v.Position.X - wx + 3 + x)*bw)
- players[i].text.setY((v.Position.Z - wy - 2 + y)*bh)
- print("Player "..i.."'s box at ("..players[i].box.getX()..", "..players[i].box.getY()..")")
- end
- end
- for i,v in pairs(players) do
- if not targets[i] then
- if v.box then
- v.box.delete()
- v.box = nil
- end
- if v.text then
- v.text.delete()
- v.text = nil
- end
- end
- end
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement