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

HELP With cooking, etc. program.

Started by Angry_Dragonoid, 07 January 2015 - 08:02 PM
Angry_Dragonoid #1
Posted 07 January 2015 - 09:02 PM
Hey, I guess I'm basicly just wondering if I can do this or not, but I want to be able to program my turtle, so that, when I run the program, it'll ask me something like, "What can I do for you, Sir?" (like a butler), and then if I say something like cook, then it'll ask, "What do you want?", and then I'll say something like, "Steak", it'll then ask, "How many?". Now this is where I'm confused. I want to make it so that I can put in ANY number, (as long as I have the stuff in storage, we'll just use 1-10 for this example), and it'll go grab the correct stuff for it, and then it'll have a database type thing, so it can look it up through the database, see what it is, see if it needs cooked, (all the information for it), and then go and cook it if it needs it, and then bring the food back. I know how to get it to move all around and everything, I just need to know how to get the editable variable (meaning the variable could be anything). I could do it normally, by creating a whole bunch of "if" statements, but I'm worried that could take a long time. I can do it, but I was just looking around for an easier way that's all. I've seen this done on sources like Youtube and such, but they never show how they did it. Please just help me out with this issue if you can, if not, please let me know, so I stop looking for a solution. Thanks

[External contact info removed. -L]
Edited on 07 January 2015 - 09:14 PM
Lyqyd #2
Posted 07 January 2015 - 10:16 PM
I removed the personal contact info you put in the post. It's generally a bad idea to post such things out in the open on the Internet.
KingofGamesYami #3
Posted 07 January 2015 - 10:33 PM
I don't understand what exactly you are asking, are you wondering how to cook the food, or remember what was cooked? If you are trying to set up a database, you should use tables

You should also note textutils.serialize can convert the table to a sttring, which can then be written to a file using the fs api.
blipman17 #4
Posted 08 January 2015 - 12:09 AM
if you try to do something like

bake 30 cake
as a program you could get 30 and cake using

vars = {...}
then you got the values you started the program in a table
Edited on 07 January 2015 - 11:21 PM
KingofGamesYami #5
Posted 08 January 2015 - 12:12 AM
Oh, you want

local tArgs = { ... }

You'll also want to use tonumber on the number, since it'll initially be a string.
blipman17 #6
Posted 08 January 2015 - 12:22 AM
me giving you the good code is also nice. :P/>
KingOfGamesYami did it right, it's {…} instead of {..}