cmud scripting help

by Caighan

Back to Mechanic's Corner.

Caighan2008-01-05 10:14:05
I am just getting into scripting in general let alone cmud. So if any of my methods sound stupid and slow please let me know how I can improve them to make my scripts better. that said here is my problem. I am scripting a Cooking system. I currently have a series of triggers that will capture the ingredients of the recipe I am looking at and store them in a database variable. this is all fine though it isn't perfect as it is about 9 different triggers. (went this way as the number of ingredients changes all the time and not sure how else to do it) Trigger basicaly looks like this...

Ingredients: (%w) (%d) (%w) (%d)

#addkey ingredients %1 %2
#addkey ingredients %3 %4

with the actual ammount changing with each trigger. Like I said works fine so far. Now through an alias I use prompts to ask me what type of food I want to cook (ie dishes or delicacies or soups etc..) then what recipe number in that type. and finaly how many batches I would like to cook. by this time it has looked at the recipe and knows what the ingredients are. here is where I run into the problem. I am so far trying to use the #loopdb command to go through the ingredients database and multiply the various values by the fore set number of batches. my current script looks like this

#loopdb @ingredients {#addkey cookcomms %key @tempvar {#math tempvar "%val*@cookamt"}}

which as far as I can tell should fill the cookcomms database with the correct ingredients and the now multiplied amounts. wherein I can use another loopdb command to pull them all out of the rift and begin cooking. I have the second loopdb command working fine only problem is the tempvar doesnt change at all. and when there is no variable at all listed there it just lists the equation and not the sum.

So thats my problem any help would be much appreciated even some better ideas about how to capture the ingredients initialy. Basicaly all I want is a nice easy way of selecting what and how much of it to cook and it gets the ingredients ready for me and lets me know if I am out of something. Hope I made that clear enough if not let me know and I will try and clarify.

Thanks for your time,
Caighan confused.gif
Unknown2008-01-05 13:29:50
CODE
#LOCAL $cookcomms
#LOOPDB @ingredients {
  #ADDKEY $cookcomms %key (%val * @cookamt)
}


This assumes that you're using the cookcomms variable immediately within that same alias, which is why I made it a local data record variable. If you're using it elsewhere, just remove the first line and change the $ to @ inside the loop.
Caighan2008-01-05 18:17:29
Thanks that seemed to do the trick.