Advertisement
justync7

ench

Jul 1st, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. shell.run("nbt")
  2. local p=peripheral.wrap("left")
  3. local world=p.getWorld(0)
  4.  
  5. function chest(x,y,z,itemid)
  6. -- Create a chest
  7. world.setBlock(x, y, z, 54, 0)
  8.  
  9. -- Get an NBT table representing the contents of the chest
  10. local te = world.getTileEntity(x, y, z)
  11. local nbt = readTileNBT(te)
  12.  
  13. table.insert(nbt.value.Items.value, {
  14. type="compound", value={
  15. id={
  16. type="short",
  17. value=itemid
  18. }, Count={
  19. type="byte",
  20. value=1
  21. }, Damage={
  22. type="short",
  23. value=0
  24. }, Slot={
  25. type="byte",
  26. value=0
  27. }, tag={
  28. type="compound",
  29. value={
  30. ["ench"]={
  31. ["type"]="list",
  32. ["value"]={
  33. [1]={
  34. ["value"]={
  35. ["id"]={
  36. ["value"]=34,
  37. ["type"]="short"
  38. }, ["lvl"]={
  39. ["value"]=100,
  40. ["type"]="short"
  41. },
  42. },
  43. ["type"]="compound"
  44. }, [2]={
  45. ["value"]={
  46. ["id"]={
  47. ["value"]=32,
  48. ["type"]="short"
  49. }, ["lvl"]={
  50. ["value"]=100,
  51. ["type"]="short"
  52. }
  53. },
  54. ["type"]="compound"
  55. }, [3]={
  56. ["value"]={
  57. ["id"]={
  58. ["value"]=0,
  59. ["type"]="short"
  60. }, ["lvl"]={
  61. ["value"]=100,
  62. ["type"]="short"
  63. }
  64. },
  65. ["type"]="compound"
  66. }, [4]={
  67. ["value"]={
  68. ["id"]={
  69. ["value"]=2,
  70. ["type"]="short"
  71. }, ["lvl"]={
  72. ["value"]=100,
  73. ["type"]="short"
  74. }
  75. },
  76. ["type"]="compound"
  77. }, [5]={
  78. ["value"]={
  79. ["id"]={
  80. ["value"]=5,
  81. ["type"]="short"},
  82. ["lvl"]={
  83. ["value"]=100,
  84. ["type"]="short"
  85. }
  86. },
  87. ["type"]="compound"
  88. }, [6]={
  89. ["value"]={
  90. ["id"]={
  91. ["value"]=6,
  92. ["type"]="short"
  93. }, ["lvl"]={
  94. ["value"]=100,
  95. ["type"]="short"
  96. }
  97. },
  98. ["type"]="compound"
  99. }, [7]={
  100. ["value"]={
  101. ["id"]={
  102. ["value"]=16,
  103. ["type"]="short"
  104. }, ["lvl"]={
  105. ["value"]=100,
  106. ["type"]="short"
  107. }
  108. },
  109. ["type"]="compound"
  110. }, [8]={
  111. ["value"]={
  112. ["id"]={
  113. ["value"]=19,
  114. ["type"]="short"
  115. }, ["lvl"]={
  116. ["value"]=100,
  117. ["type"]="short"
  118. }
  119. },
  120. ["type"]="compound"
  121. }, [9]={
  122. ["value"]={
  123. ["id"]={
  124. ["value"]=20,
  125. ["type"]="short"
  126. }, ["lvl"]={
  127. ["value"]=100,
  128. ["type"]="short"
  129. }
  130. },
  131. ["type"]="compound"
  132. }, [10]={
  133. ["value"]={
  134. ["id"]={
  135. ["value"]=21,
  136. ["type"]="short"
  137. }, ["lvl"]={
  138. ["value"]=100,
  139. ["type"]="short"
  140. }
  141. },
  142. ["type"]="compound"
  143. }, [11]={
  144. ["value"]={
  145. ["id"]={
  146. ["type"]="short",
  147. ["value"]=21
  148. }, ["lvl"]={
  149. ["value"]=100,["type"]="short"
  150. }
  151. },
  152. ["type"]="compound"
  153. }, [12]={
  154. ["value"]={
  155. ["id"]={
  156. ["value"]=35,
  157. ["type"]="short"
  158. }, ["lvl"]={
  159. ["value"]=100,
  160. ["type"]="short"
  161. }
  162. },
  163. ["type"]="compound"
  164. }, [13]={
  165. ["value"]={
  166. ["id"]={
  167. ["value"]=51,
  168. ["type"]="short"
  169. }, ["lvl"]={
  170. ["value"]=100,
  171. ["type"]="short"
  172. }
  173. },
  174. ["type"]="compound"
  175. }, [14]={
  176. ["value"]={
  177. ["id"]={
  178. ["value"]=48,
  179. ["type"]="short"
  180. }, ["lvl"]={
  181. ["value"]=100,
  182. ["type"]="short"
  183. }
  184. },
  185. ["type"]="compound"
  186. }, [15]={
  187. ["value"]={
  188. ["id"]={
  189. ["value"]=49,
  190. ["type"]="short"
  191. }, ["lvl"]={
  192. ["value"]=100,
  193. ["type"]="short"
  194. }
  195. },
  196. ["type"]="compound"
  197. }
  198. }
  199. }
  200. }
  201. }
  202. }
  203. })
  204.  
  205. writeTileNBT(te, nbt)
  206. end
  207.  
  208. while true do
  209. ev,name,msg=os.pullEvent("chat_message")
  210. if msg:sub(1,5)=="/ench" then
  211. user=p.getPlayerByName(name)
  212. ent=user.asEntity()
  213. x,y,z=ent.getPosition()
  214. chest(x,y,z,tonumber(msg:sub(7)))
  215. end
  216. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement