|
myrison Beginner
Joined: 10 Nov 2006 Posts: 22
|
Posted: Tue Jan 23, 2007 1:24 pm
Dynamically Generated Variable Names |
Hi all, once again, I'm a bit stuck, and turning to all of the experts here for assistance. Thank you in advance for the help in reviewing this.
I am trying to return the values of dynamically generated variable names based on the output of the MUD. The text that is triggering the name can take one of two forms, either a single word, or multiple.
Output from my MUD can take one of a few forms:
Single Word Variable Trigger
You have finished forging the dirk.
OR:
Multiple-Word Variable Trigger
You have finished forging the battle axe.
I want to create variables and counters based on whatever is forged, and there are about 3 dozen things that can be produced, all of which I want to create and track separately in variables.
Right now, I am doing it like this:
Code: |
TRIGGER: ^You have finished forging the (*).
#VAR tempforge %replace( %1, " ", "") // removing spaces in var name to avoid errors
#ADD %concat( @tempforge, forgecount) 1 // combining item forged (without spaces) and 'forgecount' to create varname, then incrementing by one
#SAY You have now forged approximately ????? %1. // trying to return number of items forged and the name of the item.
|
The dynamic name generation works, but the part marked with ???? I cannot figure out. I want to dynamically return the value of the same var that is created above using the %concat command. (This command makes every item forged into a variable using the format @itemforgedforgecount). I want to then return the value of that same variable using this trigger.
I have tried to return it using %concat( @,@tempforge, forgecount), but instead of returning the variable value, it returns the text like this:
Quote: |
You have now forged approximately @battleaxeforgecount battle axes.
|
i.e. it returns the name of the var, with the '@', and not the var value.
I'm sure there is a simpler way to do this, but the fact that sometimes the item forged is one word, and other times two, has created problems for me with this script.
Please let me know if anyone has suggestions. Thank you! |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Tue Jan 23, 2007 3:01 pm |
Use curly brackets to separate your variable name your building from the actual variable reference: @{@{tempforge}forgecount}
|
|
|
|
myrison Beginner
Joined: 10 Nov 2006 Posts: 22
|
Posted: Tue Jan 23, 2007 3:45 pm |
Thank you Larkin, exactly what I needed. It's often the simple things that can make you the most frustrated, thanks for saving me more hair pulling.
|
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|