Advertisement
Kagee

map-3d-backup

May 6th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. os.loadAPI("libstruct")
  2. a=aware
  3. b=libstruct
  4.  
  5. args = {...}
  6.  
  7. if #args < 5 then
  8. error("Arguments: <height> <width> <depth> <inventory> <name>")
  9. end
  10.  
  11. height=tonumber(args[1])
  12. width=tonumber(args[2])
  13. depth=tonumber(args[3])
  14. -- last block in inventory to use
  15. endblock=tonumber(args[4])
  16. name=args[5]
  17.  
  18. t={}
  19.  
  20. a.setposition("start")
  21.  
  22. height=height-1
  23. width=width-1
  24. depth=depth-1
  25.  
  26. for h=0,height do
  27. t[h] = {}
  28. for w=0,width do
  29. t[h][w] = {}
  30. end
  31. end
  32. --print (height)
  33. down = 0
  34. moveleft=true
  35. for h=0,height do
  36.  
  37. w=width
  38. while (w >= 0) do
  39. for d=0,depth do
  40. --print ("depth:",d)
  41. pos = a.getposition("current")
  42. print("Pos: h" .. pos[3]*-1 .. "-w" .. pos[1] .. "-d" .. pos[2])
  43. t[pos[3]*-1][pos[1]][pos[2]] = b.block(endblock)
  44. if(d<depth) then
  45. a.df()
  46. end
  47. end
  48. w = w - 1
  49. print("w: " .. w)
  50. print("h: " .. h)
  51. if(w < 0 and ((h-1) % 2 == 1)) then
  52. print("break")
  53. break
  54. end
  55. if(moveleft) then
  56. print("moves left")
  57. a.l()
  58. a.df()
  59. a.l()
  60. moveleft=false
  61. else
  62. print("moves right")
  63. a.r()
  64. a.df()
  65. a.r()
  66. moveleft=true
  67. end
  68. end
  69. if(h<height) then
  70. a.r()
  71. a.r()
  72. --down = h
  73. pos=a.getposition("current") -- a.getposition("start")
  74. pos[3] = pos[3] - 1--down
  75. a.goto(pos)
  76. end
  77. end
  78. a.goto(a.getposition("start"))
  79. t["height"]=height
  80. t["width"]=width
  81. t["depth"]=depth
  82. t["endblock"]=endblock
  83.  
  84. b.save(t,name..".3d")
  85. b.awarecleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement