Jump to content




"Return"/"Break" not working? [1.12.2]


1 reply to this topic

#1 Flexico

  • Members
  • 25 posts

Posted 01 November 2019 - 06:25 AM

I've been playing around on the Fabric 1.14.4 port for a while, and wrote a few turtle programs that so far have worked great. However, when I loaded up my 1.12.2 modpack and downloaded my programs, I'm running into a problem when the turtle hits bedrock. The "move forward" function is supposed to set a global variable "stuck" to "true" and exit the function. However, it doesn't exit the function and instead keeps looping through the "Unbreakable block detected" loop and ignoring the "return" command, and did the same thing when I changed it to use "break" instead. I checked to make sure I had the most recent version, and found out yes I do, but it's an alpha. >< Does anyone know a workaround for this?
Here's a bit of my code:

function fwd(n)
local x,a,b
for x=1, n or 1 do
  refuel()
  stuck = false
  while not turtle.forward() do
   a,b = turtle.dig()
   if b == "Unbreakable block detected" then
	print(B)/>/> --This prints weird on the forum for some reason
	stuck = true
	print(stuck)
	return
	print(stuck)
   end
  end
  if not stuck then
   update("fwd")
  end
end
end
When it hits bedrock, it prints out "Unbreakable block detected", "true", "true" over and over, showing the "return" command is ignored.

#2 Flexico

  • Members
  • 25 posts

Posted 02 November 2019 - 12:07 AM

This needs to be deleted! Derp me can't figure out how. I moved it to Ask a Pro like the pinned tweet told me to.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users