Advertisement
LegoStax

CommandClear

Nov 29th, 2015
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. -- Command Computer Clearing program
  2. local tArgs = {...}
  3. if not commands then
  4.     print("Command Computers only")
  5.     return
  6. end
  7. if #tArgs < 6 then
  8.     print(fs.getName(shell.getRunningProgram()).." <x1> <y1> <z1> <x2> <y2> <z2>")
  9.     return
  10. end
  11. -- filter args
  12. local x1 = math.floor(tonumber(tArgs[1]))
  13. local y1 = math.floor(tonumber(tArgs[2]))
  14. local z1 = math.floor(tonumber(tArgs[3]))
  15. local x2 = math.floor(tonumber(tArgs[4]))
  16. local y2 = math.floor(tonumber(tArgs[5]))
  17. local z2 = math.floor(tonumber(tArgs[6]))
  18. local volume = (math.abs((x1-x2)+1))*(math.abs((y1-y2)+1))*(math.abs((z1-z2)+1))
  19. -- confirmation
  20. print("Are you sure you want to delete "..volume.." blocks?")
  21. print("X1: "..tArgs[1].." Y1: "..tArgs[2].." Z1: "..tArgs[3])
  22. print("X2: "..tArgs[4].." Y2: "..tArgs[5].." Z2: "..tArgs[6])
  23. while true do
  24.     e = {os.pullEvent("key")}
  25.     if e[2] == keys.y then
  26.         print("Clearing "..volume.." blocks")
  27.         -- clear space
  28.         for y = y1,y2 do
  29.             for z = z1,z2 do
  30.                 for x = x1,x2 do
  31.                     commands.exec("/setblock "..x.." "..y.." "..z.." minecraft:air")
  32.                 end
  33.             end
  34.         end
  35.         print("Success")
  36.         break
  37.     elseif e[2] == keys.n then
  38.         print("Aborted")
  39.         break
  40.     end
  41. end
  42. coroutine.yield()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement