This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
hex450's profile picture

Unsure on how to make this functional

Started by hex450, 07 September 2013 - 10:47 AM
hex450 #1
Posted 07 September 2013 - 12:47 PM
I'm trying to make a turtle take out 640 items from a chest and once complete it will stop and do nothing until it receives a redstone pulse at which time it will take out another 640 items. I've been trying to work this out for several hours with no luck. I have gotten to a point in which it counts out the items and drops them, but once it reaches 640 it just does nothing at all. Any help will be greatly appreciated, thanks.


	count = 0
	
	function counting()
	count = count + turtle.getItemCount(1)
	return count
	end
	
	function countreset()
	count = count - count
	return count
	end
	
	while true do
	sleep(0)
	
	if count < 640 then
	turtle.suck()
	counting()
	print(count)
	turtle.drop(64)
	sleep(0.4)
	
	elseif count > 640 then
	sleep(0)
	if redstone.getInput("back",true) then
	countreset()
	print("Count has been reset.")
	end
	end
	end
Lyqyd #2
Posted 07 September 2013 - 01:10 PM
Split into new topic.

You handle the cases where count is less than 640, and the cases where count is greater than 640, but you don't handle the case where count is exactly 640.
hex450 #3
Posted 07 September 2013 - 09:02 PM
Thanks, that solved it. Much appreciated.