|
cosine_omerta Wanderer
Joined: 14 Oct 2007 Posts: 50
|
Posted: Sun Sep 19, 2010 10:46 pm
Variable Issue |
I had some aliases and variables set up so that I could easy tally up some numbers. This worked fine up until about 5 beta versions ago, and suddenly it doesn't work. I kept hoping the next beta would fix it, but no luck. This is what my code looks like:
#if (%1 = "goblin") {#add monster@trynumber.GOBLIN 1}
#if (%1 = "orc") {#add monster@trynumber.ORC 1}
This is used with an alias so that I can type 'tally goblin' and it will add to the the goblin number on trynumber 1, then a trigger changes the trynumber, and I can still use tally for the next trynumber. Then I can see the totals for each trynumber.
This will no longer save the tallies to the trynumbers. This code for saving the totals still works:
#if (%1 = "goblin") {#add monster.GOBLIN 1}
So I assume its the putting the trynumber variable in the monster db variable.
So my question is, does anybody have any suggestions for a workaround or should I keep crossing my fingers the next beta will make it work again? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Sep 20, 2010 1:53 am |
Surround trynumber.whatever in {} if you want to provide a reference to a monsterX variable.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
cosine_omerta Wanderer
Joined: 14 Oct 2007 Posts: 50
|
Posted: Mon Sep 20, 2010 2:15 am |
It still doesn't save it to the monster db variable. This is what I tried:
{#add monster@{trynumber.GOBLIN} 1} |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Sep 20, 2010 3:15 am |
Umm, you aren't referencing the @monster variable. You are referencing a variable whose name is the concatenated result of monster and whatever @trynumber.goblin is. For example, if @trynumber.goblin = 6 then your #add command is referencing the @monster6 variable.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
cosine_omerta Wanderer
Joined: 14 Oct 2007 Posts: 50
|
Posted: Mon Sep 20, 2010 3:44 am |
Not sure what you mean. I'm referencing the monster database variable, as monster2.GOBLIN, or the next variable monster3.GOBLIN, or whatever count trynumber is at. I'm sorry if I'm not saying it properly. The @trynumber is a counter variable and I'm trying to get the numbered monster db variable to be added up, but cMud won't play nice with the monster trynumber being a variable anymore.
Example. If trynumber is 2, which makes it monster2.GOBLIN, and I add 1 to the resulting monster2.GOBLIN, monster2.GOBLIN doesn't increase by 1, it stays at 0. |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Mon Sep 20, 2010 3:51 pm |
Take a look a this test code. It should do what you want.
Code: |
#LOOP 5 {
#ADDKEY monster%i GOBLIN 0
}
#VAR
#LOOP 5 {
#VAR trynumber %i
#add monster@{trynumber.GOBLIN} 1 // This doesn't work
#add {%concat("monster",@trynumber,".GOBLIN")} 1 // This does
}
#VAR |
|
|
_________________ Asati di tempari! |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Mon Sep 20, 2010 6:47 pm |
I would imagine that given the further explanation that he want to use #add monster@{trynumber}.GOBLIN 1 instead.
|
|
_________________ Taz :) |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Sep 20, 2010 6:54 pm |
Actually, the proper "official" syntax for this is:
Code: |
#LOOP 5 {
#VAR trynumber %i
#add %concat("monster",@trynumber).GOBLIN 1
} |
It's another example of trying to rely upon implicit concat when you should just be using explicit %concat instead. The part you are trying to concat is "monster" and @trynumber. The ".GOBLIN" is a key reference and really doesn't need to be part of the concat. |
|
|
|
cosine_omerta Wanderer
Joined: 14 Oct 2007 Posts: 50
|
Posted: Tue Sep 21, 2010 11:37 am |
Thanks for all the help! It's awesome that you guys take the time to help crazy people like me.
The %concat usage works perfectly!
Just for reference, the monster@{trynumber}.GOBLIN didn't work either. |
|
|
|
|
|