View difference between Paste ID: NCTRVZbr and ip1SPj7q
SHOW: | | - or go back to the newest paste.
1-
local count=0
1+
	local count=0
2-
local slot =1	 
2+
    local slot =1	 
3-
local count=0
3+
4-
local breakMode=true
4+
    if count==0 then
5-
local args = {...}
5+
    slot=slot+1;
6-
local version="0.8.5" 
6+
    count=turtle.getItemCount(slot)
7-
     --				1					2				3				4					5
7+
    if count==0 then exit() end
8-
local ftbl= {
8+
    turtle.select(slot)
9-
				{turtle.placeDown,	mdt,	turtle.digDown,	turtle.detectDown,	turtle.compareDown	},
9+
10-
				{turtle.place,		mft,	turtle.dig	,	turtle.detect	,	turtle.compare		},
10+
11-
				{turtle.placeUp,	mut,		turtle.digUp,	turtle.detectUp,	turtle.compareUp	}
11+
     
12
    count=turtle.getItemCount(slot)
13-
			}
13+
local function buildWall(x,y,z)
14-
14+
    
15-
local tx,ty,tz=0,0,0
15+
	local zr=0;
16-
local face=2;			
16+
17-
local dirinc = { {0,-1},{1,0},{0,1},{-1,0} }
17+
18-
local function tlt()
18+
19-
turtle.turnLeft()
19+
20-
face=(face+1)%4
20+
21-
end
21+
22-
local function trt()
22+
    for k=1,z do
23-
turtle.turnRight()
23+
24-
face=(face+4-1)%4
24+
25-
end
25+
26-
local function mut()
26+
27-
if not turtle.up() then return false end
27+
28-
tz=tz+1
28+
29-
return true
29+
30-
end
30+
    turtle.up()
31-
local function mdt()
31+
    
32-
if not turtle.down() then return false end
32+
	for j=1,2 do
33-
tz=tz-1
33+
            for i=1,x-2 do
34-
return true
34+
					turtle.placeDown()
35-
end
35+
					count=count-1;ensureSlot()
36-
36+
37-
37+
					turtle.placeUp()
38-
local function mft()
38+
                    count=count-1;ensureSlot()
39-
local idx = (face)%4+1
39+
40-
if not turtle.forward() then return false end
40+
					turtle.back()
41-
tx=tx+dirinc[idx][1];
41+
					if buildForward then
42-
ty=ty+dirinc[idx][2];
42+
					turtle.place()
43-
return true
43+
                    count=count-1;ensureSlot()
44-
end
44+
45-
local function mbt()
45+
            end
46-
local idx = (face+2)%4+1
46+
            turtle.placeDown()
47-
if not turtle.back() then return false end
47+
			count=count-1;ensureSlot()
48-
tx=tx+dirinc[idx][1];
48+
			if buildUp then
49-
ty=ty+dirinc[idx][2];
49+
				turtle.placeUp()
50-
return true
50+
                count=count-1;ensureSlot()
51-
end
51+
52-
52+
            turtle.turnLeft()
53
            turtle.back()
54
			if buildForward  then
55-
--write("e")
55+
				turtle.place()
56-
    if count<=0 then
56+
               count=count-1;ensureSlot()
57-
		slot=slot+1;
57+
58-
		if(slot>16) then slot=1 end
58+
     
59-
		count=turtle.getItemCount(slot)
59+
            for i=1,y-2 do
60-
		if count==0 then print("not enough blocks"); error() end
60+
					turtle.placeDown()
61-
		turtle.select(slot)
61+
					count=count-1;ensureSlot()
62
					if buildUp then
63-
end
63+
					turtle.placeUp()
64-
64+
                    count=count-1;ensureSlot()
65
					end
66-
local function digAndThrow(dir)
66+
					turtle.back()
67-
	if dir== nil  then dir=0 end
67+
					if buildForward then
68-
	local dir2=dir+2
68+
					turtle.place()
69-
	local full=false;
69+
                    count=count-1;ensureSlot()
70-
	local inv={}
70+
71-
	for i=1,16 do 
71+
            end
72-
		inv[i]=turtle.getItemCount(i)
72+
            turtle.placeDown()
73-
		if inv==0 then
73+
			count=count-1;ensureSlot()
74-
		turtle.select(i)
74+
			if buildForward and j==2 then
75-
		break
75+
					turtle.up()
76-
		end 
76+
					turtle.placeDown()
77-
		if(i==16) then 
77+
                    count=count-1;ensureSlot()
78-
			--print("failed to place block - not critical")
78+
79-
	--		return false
79+
			if buildUp then
80-
			full = true
80+
				if j==1 then
81
					turtle.placeUp()
82
                    count=count-1;ensureSlot()
83
				else
84-
	-- if all slots are 
84+
					turtle.up()
85-
	if not ftbl[dir2][3]() then turtle.select(slot);return false end
85+
					turtle.placeDown()
86-
	if not full then 
86+
                    count=count-1;ensureSlot()
87-
		turtle.drop()
87+
88-
		turtle.select(slot)
88+
89-
		return true
89+
90
            turtle.turnLeft()
91-
		for i=1,16 do 
91+
            turtle.back()
92-
				if inv[i]~=turtle.getItemCount(i) then
92+
			if buildForward and j==1 then
93-
				   turtle.select(i)
93+
				turtle.place()
94-
				   turtle.drop(turtle.getItemCount(i)-inv[i])
94+
               count=count-1;ensureSlot()
95-
				   turtle.select(slot)
95+
96-
				   return true
96+
     
97
    end
98
    end
99
	
100-
	return true
100+
	turtle.forward()
101-
end
101+
102-
--[[
102+
	local function buildPlate(x,y)
103-
function fCirc(x,r)
103+
	turtle.up()
104-
return math.sqrt(r*r-x*x)
104+
105-
end
105+
106-
106+
107-
function followCirclePath()
107+
	        turtle.placeDown()
108-
local i=1
108+
			count=count-1;ensureSlot()
109-
while true do
109+
			   turtle.back()
110-
110+
111-
111+
			turtle.placeDown()
112-
end
112+
			count=count-1;ensureSlot()
113-
end
113+
114-
]]--
114+
			if(j%2== 1) then turtle.turnLeft() else turtle.turnRight() end
115-
function backSpecial()
115+
	        turtle.back()
116-
	while not mbt() do 
116+
117-
		if breakMode then 
117+
            if(j%2== 1) then turtle.turnLeft() else turtle.turnRight() end
118-
		trt();trt();
118+
119-
			if not digAndThrow(0) then 
119+
120-
				print("obsticle found:waiting...");sleep(1) 
120+
    
121-
			else 
121+
122-
				--return false
122+
123
	
124-
		trt();trt();
124+
	print("make sure the turtle is refueld ")
125
	print("load building material in all slots")
126-
			print("obsticle found:waiting...");sleep(1) 
126+
	print("	place turtle at bottom right corner (builds in place)")
127
    print("first wall?")
128
    local x1=tonumber(read())
129-
	return true
129+
    print("second wall?")
130-
end
130+
    local y1=tonumber(read())
131-
131+
    print("height?")
132-
function upSpecial()
132+
    local z1=tonumber(read())
133-
while not mut() do 
133+
    local sel=0
134-
	if not digAndThrow(1) then 
134+
turtle.select(1)
135-
		print("can't move up")
135+
136-
		sleep(1)
136+
	print("0= walls 1 = add floor ,2 = add roof 3= add both" )
137-
	end 
137+
138-
end
138+
	until(sel>=0 and sel<=3) 
139-
end
139+
	turtle.turnRight();turtle.turnRight();
140-
140+
	if((sel==1 or sel==3) and z1>0) then 
141-
141+
		buildPlate(x1,y1);
142-
local function tp(dir)
142+
		z1=z1-1; 
143-
	if dir== nil  then dir=0 end
143+
		if(y1%2==1) then 
144-
	local dir2=dir+2
144+
		turtle.turnRight();turtle.turnRight();
145
		else
146-
	if ftbl[dir2][1]() then
146+
		turtle.turnLeft();
147-
		count=count-1
147+
148-
		ensureSlot()
148+
149
	turtle.back()
150-
		if  digAndThrow(dir) then 
150+
	if ((sel==2 or sel==3 )and z1>1) then
151-
			if ftbl[dir2][1]() then
151+
	buildWall(x1,y1,z1-1)
152-
				count=count-1
152+
	buildPlate(x1,y1)
153-
				ensureSlot()
153+
154
	if(z1>0) then buildWall(x1,y1,z1) end
155
	end
156-
			print("failed to place block - not critical")
156+
	 
157
    --if(zr~=0) then z=z-1; end
158
	--z=z*3+zr
159-
end
159+
	--for i=1,z do turtle.down() end