I dont think this will work anywhere besides in minecraft with computercraft but it's all correct syntax. I just feel like it has some lines of code I could eliminated somehow and made it a cleaner script. I appreciate any constructive criticism to help me further understand what I'm misunderstanding.
function placef()
turtle.select(1)
x = 1
if turtle.getItemCount(x) == 0 then
repeat turtle.select(x+1)
x = x + 1
if x == 17 then
x = 1
y = 2
end
if y == 2 then
os.reboot()
end
until turtle.getItemCount(x) > 0
end
turtle.place()
end
function placeup()
turtle.select(9)
x = 9
if turtle.getItemCount(x) == 0 then
repeat turtle.select(x+1)
x = x + 1
if x == 17 then
x = 9
y = 2
end
if y == 2 then
os.reboot()
end
until turtle.getItemCount(x) > 0
end
turtle.placeUp()
end
function place()
turtle.select(9)
x = 9
if turtle.getItemCount(x) == 0 then
repeat turtle.select(x+1)
x = x + 1
if x == 17 then
x = 9
y = 2
end
if y == 16 then
os.reboot()
end
until turtle.getItemCount(x) > 0
end
turtle.placeDown()
end
function repairOT()
turtle.select(1)
x = 1
if turtle.getItemCount(x) == 0 then
repeat turtle.select(x+1)
x = x + 1
if x == 17 then
x = 1
y = 2
end
if y == 2 then
os.reboot()
end
until turtle.getItemCount(x) > 0
end
if turtle.compareDown() == false then
place()
turtle.turnRight()
else
turtle.turnRight()
end
if turtle.compare() == false then
placef()
turtle.turnLeft()
else
turtle.turnLeft()
end
turtle.forward()
end
function repairBI()
turtle.select(1)
x = 1
if turtle.getItemCount(x) == 0 then
repeat turtle.select(x+1)
x = x + 1
if x == 17 then
x = 1
y = 2
end
if y == 16 then
os.reboot()
end
until turtle.getItemCount(x) > 0
end
if turtle.compareUp() == false then
placeup()
turtle.turnLeft()
else
turtle.turnLeft()
end
if turtle.compare() == false then
placef()
turtle.turnRight()
else
turtle.turnRight()
end
turtle.forward()
end
These functions are where I think I could do away with alot of lines of code but I'm not sure how. Maybe an anonymous function and a class. Don't really quite understand using those very well yet.
https://pastebin.com/JDZSibmn There is the full script just in case anyone wants to see it. The rest is just loops.
os.reboot()
in a Minecraft plug-in and I'm all lost again. \$\endgroup\$