View difference between Paste ID: qyemJJGw and zCJGjK4q
SHOW: | | - or go back to the newest paste.
1
os.loadAPI("findBlocks.lua")
2
os.loadAPI("userInput.lua")
3-
slot = 1
3+
cost = 0
4-
-- Function to build a floor
4+
5-
function placeDown()
5+
function setCost(newCost)
6-
	while not turtle.placeDown() do
6+
	cost = newCost
7-
			if slot == 16 then
7+
8-
				slot = 1
8+
9-
				turtle.select(slot)
9+
function getCost()
10-
				print("Out of Materials")
10+
	return cost
11-
				print("Please Insert Blocks")
11+
12-
				userInput.getUserInput("Type Anything to Continue")
12+
13-
			else
13+
function predictFloor(newlength, newwidth)
14-
				slot = slot + 1
14+
    width = tonumber(newwidth)
15-
				turtle.select(slot)
15+
	length = tonumber(newlength)
16
	print(width)
17
	print(length)
18
	for i = 1, length do
19
        for j = 1, width do
20-
function getBlocks(blockname)
20+
21-
	slot = findBlocks.findBlock(blockname)
21+
                cost = cost + 1
22-
	while slot == nil do
22+
23-
		print("Please input more ")
23+
24-
		print(blockname)
24+
25-
		userInput.getUserInput("Type Anything to Continue")
25+
26
                cost = cost + 1
27-
	return slot
27+
28
				cost = cost + 1
29
            end
30-
function smartPlaceDown(blockname)
30+
31-
	local itemDetail = turtle.getItemDetail(slot)
31+
32-
	if itemDetail and itemDetail.name ~= blockName then
32+
33-
		slot = getBlocks(blockname)
33+
34-
		if slot ~= nil then
34+
function predictWalls(newlength, newwidth, newHeight)
35-
			turtle.select(slot)
35+
	width = tonumber(newwidth - 2)
36
	length = tonumber(newlength - 2)
37
	height = tonumber(newHeight) 
38-
	while not turtle.placeDown() do
38+
39-
		slot = getBlocks(blockname)
39+
40-
		if slot ~= nil then
40+
41-
			turtle.select(slot)
41+
42
		else
43
			distance = width
44-
	return slot
44+
45
46
		for j = 1, distance do
47-
function buildFloor(newlength, newwidth)
47+
			cost = cost + 1
48-
    width = newwidth
48+
49-
	length = newlength
49+
            	cost = cost + 1
50
            end
51
			predictSupportBeam(height)
52-
            placeDown()
52+
53
		cost = cost + 1
54-
                turtle.forward()
54+
55
end
56
57
function predictSupportBeam(newHeight)
58
		height = tonumber(newHeight)
59-
                turtle.turnLeft()
59+
		cost = cost + 1
60-
                turtle.forward()
60+
61-
                turtle.turnLeft()
61+
62
                cost = cost + 1
63-
				turtle.turnRight()
63+
64-
                turtle.forward()
64+
65-
                turtle.turnRight()
65+
66
67
function predictSupportBeams(height, orientation)
68
		width = width - 1
69
		length = length - 1
70
		for i = 1, 4 do
71-
function buildFloorBlock(newlength, newwidth, blockname)
71+
				predictSupportBeam(height)
72-
    width = newwidth
72+
73-
	length = newlength
73+
74
					distance = length
75
				end
76-
            smartPlaceDown(blockname)
76+
77
					distance = width
78-
                turtle.forward()
78+
79
80
				for j = 1, distance do
81
					cost = cost + 1
82
				end
83-
                turtle.turnLeft()
83+
84-
                turtle.forward()
84+
                    cost = cost + 1
85-
                turtle.turnLeft()
85+
86
		end
87-
				turtle.turnRight()
87+
88-
                turtle.forward()
88+
89-
                turtle.turnRight()
89+
				cost = cost + 1
90
			end
91
		else 
92
			for l = 1, width do
93
				cost = cost + 1
94
			end
95-
function buildWalls(newlength, newwidth, height)
95+
96-
	width = newwidth - 2
96+
97-
	length = newlength - 2 
97+
				cost = cost + 1
98
			end
99
100
		end
101
end
102
103
function setOrientation(newWidth)
104
	newwidth = tonumber(newWidth)
105
	orientation = 0
106
	if newwidth % 2 == 1 then
107-
			turtle.forward()
107+
108
	else
109-
            	turtle.down()
109+
110
	end
111-
			buildSupportBeam(height)
111+
112
113-
		turtle.forward()
113+
function predictFullBuild(newlength, newwidth, height)
114-
		turtle.turnRight()
114+
	cost = cost + 1
115
	predictFloor(newwidth, newlength)
116
	setOrientation(newwidth)
117
	predictSupportBeams(height, orientation)
118-
function buildWallsBlock(newlength, newwidth, height, blockname)
118+
	predictWalls(newlength, newwidth, height)
119-
	width = newwidth - 2
119+
120-
	length = newlength - 2 
120+