Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. --[[    CrateAPI
  2.   Easily summon chests
  3.       with items!
  4.      By RodrickLord ]]
  5.  
  6. if not commands then
  7.   error("Crate API needs a Command Computer!", 0)
  8. end
  9.  
  10. function RandomSpawn()
  11.   X = math.random(40)
  12.   Y = math.random(38)
  13. end
  14.  
  15.  
  16.  
  17.  
  18. -- Thx awsumben13 for help in this function
  19. local function formatTable(t)
  20.   local s = ""
  21.   for i, v in ipairs(t) do
  22.     if type(v) == "table" then
  23.       local tagType = ""
  24.       v.data = v.data or 0
  25.       s = s .. "," .. ("{id:%d,Count:%db,Slot:%db,Damage:%ds}"):format(v.id,v.count,v.slot,v.data)
  26.     end
  27.   end
  28.   return s:sub( 2 )
  29. end
  30.  
  31. function summonCrate(x,y,z,itemTable)
  32.   local items = formatTable(itemTable)
  33.   commands.summon("FallingSand",x,y,z,"{TileID:54,Time:1,TileEntityData:{Items:["..items.."]}}")
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement