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

Turtle bakery question

Started by NorwayKtm, 01 September 2014 - 02:49 PM
NorwayKtm #1
Posted 01 September 2014 - 04:49 PM
Hey all!
I'm trying to do a bakery with a terminal that sends the signal to a turtle, which will bake the bred.
I want, that the customer can choose how many breds he wants. So I did this:


print("Wie viel Brot soll ich machen?")
local anzahl = io.read()
rednet.send(13,anzahl)

Simple, but I think useful.
When the customer put in for example: "4", then "4" will be sent to the turtle. And what to do now on the turtle? I already put some chests in a room and the turtle already knows how it can get there^^
But how can I programme it that only the given amount will be smelt?

Thanks for help :wub:/>
Saldor010 #2
Posted 02 September 2014 - 12:05 AM
The problem is, you're sending a string over, and your program wants a number. So to turn the string to a number, just add in this line.


local anzahl = tonumber(anzahl)

But, you also need to check if what the person is sending over is a valid number. So to check for that, just do this.


if anzahl == nil then
  print("That's not a valid number, silly!")
  sleep(1)
  --#Your code to grab the number again
end
Edited on 01 September 2014 - 10:06 PM
Bomb Bloke #3
Posted 02 September 2014 - 12:32 AM
To actually get the bread into the furnace, have the turtle move over the top of it, then use turtle.dropDown().

To extract the cooked bread, move in front of the furnace, then use turtle.suck().