View difference between Paste ID: k2jMF07w and JuPu26N4
SHOW: | | - or go back to the newest paste.
1-
os.loadAPI("libstruct")
1+
fs.delete("aware.current")
2
os.loadAPI("aware")
3-
b=libstruct
3+
4
function block(endblock)
5-
args = {...}
5+
	for i=1,endblock do
6
		turtle.select(i)
7-
if #args < 5 then
7+
		if turtle.compareDown() then
8-
        error("Arguments: <height> <width> <depth> <inventory> <name>")
8+
			turtle.digDown()
9
			return i
10-
 
10+
11-
height=tonumber(args[1])
11+
12-
width=tonumber(args[2])
12+
	-- destroy unknown blocks
13-
depth=tonumber(args[3])
13+
	turtle.digDown()
14-
-- last block in inventory to use
14+
	return 0
15-
endblock=tonumber(args[4])
15+
16-
name=args[5]
16+
17-
 
17+
function place(i)
18-
t={}
18+
	if (i > 0) then
19-
--print("Setting start")
19+
		turtle.select(i)
20-
a.setposition("start")
20+
		if (not turtle.compareDown()) then
21
			-- remove wrong block 
22-
height=height-1
22+
			turtle.digDown()
23-
width=width-1
23+
			if (turtle.getItemCount(i) < 2 ) then
24-
depth=depth-1
24+
				print("Sleeping while waiting for refill in slot " .. i)
25-
parwidth=(width %2 == 0) -- width er partall
25+
				while (turtle.getItemCount(i) < 2 ) do
26-
moveleft = true
26+
					os.sleep(15)
27
				end
28-
for h=0,height do
28+
29-
        t[h] = {}
29+
			if (not turtle.placeDown()) then
30-
        for w=0,width do
30+
				error("Unable to place")
31-
                t[h][w] = {}
31+
32-
        end
32+
33
	end
34
end
35-
function line()
35+
36-
	--print("Mapping line")
36+
function ml()
37-
	for d=0,depth do
37+
	a.l()
38-
		pos = a.getposition("current") 
38+
	a.df()
39-
                --print("Pos: h" .. pos[3]*-1 .. "-w" .. pos[1] .. "-d" .. pos[2])
39+
	a.r()
40-
                t[pos[3]*-1][pos[1]][pos[2]] = b.block(endblock)
40+
41-
		if(d<depth) then
41+
42-
			a.df()
42+
function mr()
43
	a.r()
44
	a.df()
45
	a.l()
46
end
47-
function turn()
47+
48-
	if(moveleft) then
48+
function t180()
49-
		--print("Moving left")
49+
	a.r()
50-
		a.l()
50+
	a.r()
51-
		a.df()
51+
52-
		a.l()
52+
53-
	else
53+
function save(table,name)
54-
		--print("Moving right")
54+
	local file = fs.open(name,"w")
55-
		a.r()
55+
	file.write(textutils.serialize(table))
56-
		a.df()
56+
	file.close()
57-
		a.r()
57+
58
59-
	moveleft = not moveleft
59+
function load(name)
60
	local file = fs.open(name,"r")
61
	local data = file.readAll()
62-
function layer()
62+
	file.close()
63-
	--print("Mapping layer")
63+
	return textutils.unserialize(data)
64-
	for w=0,width do
64+
65-
		line()
65+
function awarecleanup()
66-
		if(w<width) then
66+
	fs.delete("aware.current")
67-
			turn()
67+
	fs.delete("aware.start")
68
end