Im having problems with this verb. When I add one var to the statpanel it works just fine,but when I add more then one.... well its turns out like this.
Lets say i added one var and named it Hp and its value 10. It would turn out like this.
Hp 10
But. Lets say i add another var. Erm.. Mp and its value 10. It in turn would look like this.
Hp 10
HP 10
MP 10
MP 10
Lets add a third var. Gold and its value 100. It would then appear like this.
Hp 10
HP 10
HP 10
MP 10
MP 10
MP 10
Gold 100
Gold 100
Gold 100
Etc. How can I fix this. The verb is below.
mob/var/list/tmpvars[] = list()
mob/var/list/tmpval[] = list()
mob
Stat()
statpanel("Variables")
for(var/v in tmpvars)
for(var/val in tmpval)
stat("[v]","[val]")
mob
verb
Addvar(mob/M as mob in world)
var/v = input("What is the new var?") as text
if(v)
var/val = input("What would you like to set it to?") as text
tmpvars += v
tmpval += val
ID:177572
Aug 25 2002, 4:42 pm
|
|
In response to Lummox JR
|
|
That didn't make any sense -.-. Im trying to make a verb for my text mud to where the host can creat a var to the statpanel. Like in airson mud.
|
In response to Jacob
|
|
Jacob wrote:
That didn't make any sense -.-. Im trying to make a verb for my text mud to where the host can creat a var to the statpanel. Like in airson mud. If that didn't make sense, read in the reference on how to use lists, then check again. What I'm telling you is that you need to use one list, not two, and use associated values. All the info you need about this is in the reference, and in my BYONDscape column (non-subscription content) on associated lists; check the BYONDscape archives. Lummox JR |
First, you can fix it the wrong way: Create a new var, i, and loop that from 1 to the length of either list. Then print out the stats like so:
But this is the wrong way, because it still uses two lists.
The right way to do this is to use an associative list:
Then your stat loop would look like this:
You'll find it easier to maintain one list than two, plus you'll have fewer potential bugs. A quick way of defining the list might look like this:
Lummox JR