Jump to content




Attempt to call boolien?


  • You cannot reply to this topic
6 replies to this topic

#1 subzero22

  • Members
  • 97 posts

Posted 05 February 2014 - 12:08 PM

For some odd reason I keep getting an attemp to call boolien on line 73 and I can't figure out why it's happening. The print stuff is temporary and for getting bugs out of my code.

Http//:www.pastebin.com/Yy1zc3kc

Edited by subzero22, 05 February 2014 - 12:11 PM.


#2 OReezy

  • Members
  • 91 posts

Posted 05 February 2014 - 12:18 PM

On line 66 you overwrite you function with false.

Edited by OReezy, 05 February 2014 - 12:19 PM.


#3 subzero22

  • Members
  • 97 posts

Posted 05 February 2014 - 01:52 PM

Thanks. It works now but it seems no matter where I put x = false to reset it I get that error. Even at the bottom in the while loop line.

Is there a way I can reset it back to false?

#4 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 05 February 2014 - 02:35 PM

Here is your code which I posted for others to review. I could not spot the problem.

x = false

function border()
print("checking")
  turtle.select(16)
  if turtle.compare() == true then
		turtle.turnLeft()
	if turtle.forward() == false then
	  turtle.back()
	  turtle.turnLeft()
	end
  end
end

function glow()
  print("glow")
  turtle.select(15)
  if turtle.compare() == true then
	glow = true
  else
	glow = false
  end
end

function dump()
  turtle.select(14)
  turtle.placeDown()
  s = 1
  for i=1,13 do
	turtle.select(s)
	turtle.dropDown(64)
	s = s + 1
	sleep(0.2)
  end
  turtle.select(14)
  turtle.digDown()
end

function forward()
print("forward")
  while not turtle.forward() do
	border()
	turtle.select(1)
	turtle.dig()
	turtle.attack()
	sleep(0.5)
  end
end  

function turn()
  if x == false then
	turtle.turnLeft()
	forward()
	turtle.turnLeft()
	x = true
  else
	turtle.turnRight()
	forward()
	turtle.turnRight()
	x = false
  end
end

function dig()
  if glow == true then
	turn = false
	print("digging")
	forward()
	for i = 1,3 do
	  forward()
	  forward()
	  print(x)
	  turn()
	end
	forward()
	dump()
  else
	sleep(120)
  end
end

while true do

border()
glow()
dig()

end

You could declare x as a local x at the beginning.

Edited by surferpup, 05 February 2014 - 02:36 PM.


#5 OReezy

  • Members
  • 91 posts

Posted 05 February 2014 - 02:36 PM

Post your new code. I don't see anything wrong in the old code if you only changed that one thing.

Also, I just noticed in one of your loops you use this
s = 1
  for i=1,13 do
	turtle.select(s)
	turtle.dropDown(64)
	s = s + 1
	sleep(0.2)
  end
You can just use i from the for loop:
  for i=1,13 do
	turtle.select(i)
	turtle.dropDown(64)
	sleep(0.2)
  end


#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 05 February 2014 - 06:30 PM

When you do this:

function someVar()
  print("This is a function")
end

... you're defining a function, which is assigned to the "someVar" variable. "someVar()" calls the function in "someVar".

Say you later do this:

someVar = true

Now "someVar" no longer leads to a function, but instead has a boolean (true/false) value stored against it. "someVar()" would attempt to call a function in "someVar", but since it now contains a boolean instead, you can guess what error comes up.

This means that eg calling your "glow" function results in it replacing itself with a boolean, and calling your "dig" function may result in your "turn" function being affected the same way.

#7 6677

  • Members
  • 197 posts
  • LocationCambridgeshire, England

Posted 06 February 2014 - 07:54 AM

Heres a major problem:
function glow()
print("glow")
turtle.select(15)
if turtle.compare() == true then
glow = true
else
glow = false
end
end

You create a function glow(). Then you overwrite glow() with true or false so instead of glow being a function it is a boolean. There is your issue.

Swap glow = true for return true.

I think you need to look at the lua API documentation on how functions work.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users