I´ve tried declaring the variables with _G
., and putting a return statement at the end of the functions, right before the last "end". First of which gave me an error and the other didn't solve anything.
X = 0
Y = 0
Z = 0
BedrockLevel = 0
CurrentLayer = 5
succsess = true
function DigDown(BedrockLevel, CurrentLayer, Z, succsess)
while BedrockLevel == 0 do
succsess = turtle.digDown()
if succsess == false then
succsess = turtle.down()
if succsess == false then
BedrockLevel = Z - 1
else
Z = Z - 1
end
end
succsess = turtle.down()
if succsess == true then
Z = Z - 1
end
end
while Z < BedrockLevel + CurrentLayer do
succsess = turtle.up()
if succsess == true then
Z = Z + 1
end
end
return BedrockLevel, CurrentLayer, Z, succsess
end
DigDown(BedrockLevel, CurrentLayer, Z, succsess)
print(BedrockLevel, X, Y, Z)
the expected outcome was: the print-funtion shows: -10 0 0 5,
but it says 0 0 0 0.
since this is the value that is assigned at the top of the code, I assume that the function doesn't change it, even though there is a return statement.