Advertisement
Wired2coffee

PROGRAM CRASH

Jun 5th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2.  
  3. local sensor = sensor.wrap("left")
  4. local glass = peripheral.wrap("right")
  5.  
  6. local wx, wy = -8.5, -8.5 -- world x/y
  7. local x, y = 5, 5
  8. local w, h = 60, 60
  9. local bw, bh = w/20, h/20 -- block w/h
  10.  
  11. glass.clear()
  12.  
  13. local grassbox = glass.addBox(x, y, w, h, 0x32C82D, 1)
  14. grassbox.setZIndex(0)
  15. local building = glass.addBox(x+(bw*3), y+(bh*3), w-(bw*6), h-(bh*6), 0x999999, 1)
  16. building.setZIndex(1)
  17. local z = 2
  18.  
  19. local dont_add = {
  20. "Chicken%d+",
  21. "Cow%d+",
  22. "Sheep%d+",
  23. "Pig%d+",
  24.  
  25. "Zombie%d+",
  26. "Skeleton%d+",
  27. "Spider%d+",
  28. "Creeper%d+",
  29. "Enderman%d+",
  30. "Bat%d+",
  31. "Witch%d+",
  32. }
  33.  
  34. local players = {}
  35.  
  36. while true do
  37. local targets = sensor.getTargets()
  38. for i, v in pairs(targets) do
  39. local add = true
  40. for k,l in pairs(dont_add) do
  41. if string.find(i, l) then
  42. add = false
  43. end
  44. end
  45. if add then
  46. if not players[i] then
  47. players[i] = {}
  48. print("Added player: "..i)
  49. end
  50. if not players[i].box then
  51. players[i].box = glass.addBox(0, 0, 4, 4, 0xFF0000, 1)
  52. players[i].box.setZIndex(z)
  53. players[i].text = glass.addText(0, 0, i, 0x000000)
  54. players[i].text.setZIndex(z+1)
  55. z = z + 2
  56. end
  57. players[i].box.setX((v.Position.X - wx - 2 + x)*bw)
  58. players[i].box.setY((v.Position.Z - wy - 2 + y)*bh)
  59. players[i].text.setX((v.Position.X - wx + 3 + x)*bw)
  60. players[i].text.setY((v.Position.Z - wy - 2 + y)*bh)
  61.  
  62. print("Player "..i.."'s box at ("..players[i].box.getX()..", "..players[i].box.getY()..")")
  63. end
  64. end
  65. for i,v in pairs(players) do
  66. if not targets[i] then
  67. if v.box then
  68. v.box.delete()
  69. v.box = nil
  70. end
  71. if v.text then
  72. v.text.delete()
  73. v.text = nil
  74. end
  75. end
  76. end
  77. sleep(0.1)
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement