Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. local component = require("component")
  2. local os = require("os")
  3. local computer = require("computer")
  4. local event = require("event")
  5. local term = require("term")
  6.  
  7. local c = component.chat_box
  8. local g = component.gpu
  9. local d = component.debug
  10.  
  11. local n=5
  12. local cordx={-270,-268,-266,-264,-262}
  13. local cordy={5,5,5,5,5}
  14. local cordz={-66,-66,-66,-66,-66}
  15. local chest={1,2,3,4,5}
  16. local che=5
  17.  
  18. function prov(i)
  19. if d.getWorld().getBlockId(cordx[i],cordy[i]-3,cordz[i])==35 then
  20. che=che-1
  21. chest[i]=-1
  22. if che==4 then
  23. c.say("Залишилось 4 сундука")
  24. end
  25. if che==3 then
  26. c.say("Залишилось 3 сундука")
  27. end
  28. if che==2 then
  29. c.say("Залишилось 2 сундука")
  30. end
  31. if che==1 then
  32. c.say("Залишився 1 сундук")
  33. end
  34. if che==0 then
  35. c.say("Сундуків нема!")
  36. os.sleep(10)
  37. for j=1,n do
  38. for k=1,27 do
  39. d.getWorld().removeItem(cordx[j],cordy[j],cordz[j],k)
  40. end
  41. d.getWorld().setBlock(cordx[j],cordy[j],cordz[j],0,0)
  42. end
  43. end
  44. os.sleep(3)
  45. end
  46. end
  47.  
  48. function insert(i)
  49. local random=math.random(1,3)
  50. if (random==1) then
  51. d.getWorld().insertItem("customnpcs:npcEarthElement", 3, 0, "", cordx[i],cordy[i],cordz[i], 1)
  52. d.getWorld().insertItem("IC2:itemIngot", 2, 0, "", cordx[i],cordy[i],cordz[i], 1)
  53. d.getWorld().insertItem("minecraft:gold_ingot", 1, 0, "", cordx[i],cordy[i],cordz[i], 1)
  54. end
  55. if (random==2) then
  56. d.getWorld().insertItem("customnpcs:npcEarthElement", 2, 0, "", cordx[i],cordy[i],cordz[i], 1)
  57. d.getWorld().insertItem("minecraft:diamond", 2, 0, "", cordx[i],cordy[i],cordz[i], 1)
  58. d.getWorld().insertItem("minecraft:gold_ingot", 2, 0, "", cordx[i],cordy[i],cordz[i], 1)
  59. end
  60. if (random==3) then
  61. d.getWorld().insertItem("customnpcs:npcEarthElement", 1, 0, "", cordx[i],cordy[i],cordz[i], 1)
  62. d.getWorld().insertItem("minecraft:diamond", 1, 0, "", cordx[i],cordy[i],cordz[i], 1)
  63. d.getWorld().insertItem("IC2:itemIngot", 1, 0, "", cordx[i],cordy[i],cordz[i], 1)
  64. d.getWorld().insertItem("ender_pearl", 1, 0, "", cordx[i],cordy[i],cordz[i], 1)
  65. end
  66. end
  67.  
  68. function spawn()
  69. for i=1,5 do
  70. d.getWorld().setBlock(cordx[i],cordy[i],cordz[i],146,0)
  71. d.getWorld().setBlock(cordx[i],cordy[i]-1,cordz[i],33,0)
  72. d.getWorld().setBlock(cordx[i],cordy[i]-2,cordz[i],35,0)
  73. d.getWorld().setBlock(cordx[i],cordy[i]-3,cordz[i],0,0)
  74. insert(i)
  75. end
  76. end
  77.  
  78. spawn()
  79.  
  80. while true do
  81. for i=1,n do
  82. flag=1
  83. for j=1,n do
  84. if i==chest[j] then
  85. flag =0
  86. end
  87. end
  88. if flag==0 then
  89. prov(i)
  90. end
  91. end
  92. if che ==0 then
  93. c.say("Закритие програмки")
  94. break
  95. end
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement