Advertisement
Captain_Kyros

Schematic API

May 27th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. -- Schematic API
  2. -- by MysticT
  3.  
  4. function load(sPath)
  5.     local tags, err = nbt.readNBTFile(sPath)
  6.     if tags == nil then
  7.         return nil, err
  8.     end
  9.     if tags[1].name ~= "Schematic" then
  10.         return nil, "Not an schematic file"
  11.     end
  12.     return tags[1].payload
  13. end
  14.  
  15. function getBlocks(schem)
  16.     local blocks, data
  17.     for _,tag in ipairs(schem) do
  18.         if tag.name == "Blocks" then
  19.             blocks = tag.payload
  20.         elseif tag.name == "Data" then
  21.             data = tag.payload
  22.         end
  23.     end
  24.     return blocks, data
  25. end
  26.  
  27. function getSize(schem)
  28.     local width, height, length
  29.     for _,tag in ipairs(schem) do
  30.         if tag.name == "Width" then
  31.             width = tag.payload
  32.         elseif tag.name == "Height" then
  33.             height = tag.payload
  34.         elseif tag.name == "Length" then
  35.             length = tag.payload
  36.         end
  37.     end
  38.     return width, height, length
  39. end
  40.  
  41. function getMaterials(schem)
  42.     for _,tag in ipairs(schem) do
  43.         if tag.name == "Materials" then
  44.             return tag.payload
  45.         end
  46.     end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement