Advertisement
Guest User

pyramid

a guest
Dec 10th, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. --[[
  2.   Brief notes:
  3.   This code is under WTFPL license
  4.   English isn't my first language
  5.   I won't update this thing
  6.   I'm not pround of my ugly script ]]
  7.  
  8. -- Stores the command argumments
  9. local args = {...}
  10.  
  11. -- Check if there are arguments...
  12. if args[1] and args[2] and args[3] and args[4] and args[5] == nil then
  13.  
  14.    -- Raise an error if argurments are empty
  15.    error("Usage: pyramid <x> <y> <z> <BaseSize> <TileName> [hollowness: true/false]\n E.g.: pyramid 100 54 33 20 minecraft:stone true)")
  16. end
  17.  
  18. -- Set the pyramid base size (in blocks)
  19. local size = args[4]
  20.  
  21. -- Set the origin position
  22. local xa, y, za = args[1], args[2], args[3]
  23.  
  24. -- Get the opposite position by adding the base size
  25. local xb, zb = (xa-1) + size, (za-1) + size
  26.  
  27. -- The height limit
  28. local hlimit = math.ceil((size/2))
  29.  
  30. -- "While 'current pyramid height' is less than 'pyramid total height'"
  31. for h = 0, hlimit - 1 do
  32.  
  33.    -- Fill the layer with blocks  
  34.    exec(string.format("fill %s %s %s %s %s %s %s",xa+h,y+h,za+h,xb-h,y+h,zb-h,args[5]))
  35.    
  36.    -- If user wants a hollow pyramid
  37.    if args[6] == "true" and h < hlimit - 1 then
  38.    
  39.      -- Fill the layer except the border with air
  40.      exec(string.format("fill %s %s %s %s %s %s minecraft:air",xa+h+1,y+h,za+h+1,xb-h-1,y+h,zb-h-1))
  41.    end  
  42.    
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement