View difference between Paste ID: JuPu26N4 and sbS3KuV1
SHOW: | | - or go back to the newest paste.
1-
os.loadAPI("aware")
1+
os.loadAPI("libstruct")
2
a=aware
3-
height=3
3+
b=libstruct
4-
width=3
4+
5-
depth=3
5+
args = {...}
6-
filename="test-1"
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
--print("Setting start")
20
a.setposition("start")
21
22
height=height-1
23
width=width-1
24
depth=depth-1
25
parwidth=(width %2 == 0) -- width er partall
26
moveleft = true
27
28
for h=0,height do
29
        t[h] = {}
30
        for w=0,width do
31
                t[h][w] = {}
32
        end
33
end
34
35
function line()
36
	--print("Mapping line")
37
	for d=0,depth do
38
		pos = a.getposition("current") 
39
                --print("Pos: h" .. pos[3]*-1 .. "-w" .. pos[1] .. "-d" .. pos[2])
40
                t[pos[3]*-1][pos[1]][pos[2]] = b.block(endblock)
41
		if(d<depth) then
42
			a.df()
43
		end
44
	end
45
end
46
47
function turn()
48
	if(moveleft) then
49
		--print("Moving left")
50
		a.l()
51
		a.df()
52
		a.l()
53
	else
54
		--print("Moving right")
55
		a.r()
56
		a.df()
57
		a.r()
58
	end
59
	moveleft = not moveleft
60
end
61
62
function layer()
63
	--print("Mapping layer")
64
	for w=0,width do
65
		line()
66
		if(w<width) then
67
			turn()
68
		end
69
	end
70
end
71
72
for h=0,height do
73
	layer()
74
	if not (h == height) then
75
		a.dd()
76
		b.t180()
77
		if parwidth then
78
			if h%2 == 0 then
79
				turnleft=false
80
			else
81
				turnleft=true	
82
			end
83
		else
84
			turnleft=true
85
		end
86
	end
87
end
88
89
--print("Finised, going home")
90
a.goto(a.getposition("start"))
91
92
t["height"]=height
93
t["width"]=width
94
t["depth"]=depth
95
t["endblock"]=endblock
96
 
97
b.save(t,name .. ".3d")
98
print("Saved to ".. name .. ".3d")
99
b.awarecleanup()