Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
kadath
Newbie


Joined: 07 May 2003
Posts: 2

PostPosted: Tue May 13, 2003 6:41 am   

spell tracker problems
 
After 6 years in tintin I finally capitulated last week and switched to zmud (for the mapping mainly) and I've been trying to develop a spelltracker for my druid on Arctic. While I've got it close to working I'm running into a problem with a list holding values that confuse me. I realise the code is fairly rough and that there's a lotta stuff in there that's fairly redundant but I'd appreciate any advice.

Mud output:
---------------------------------------------

Spells currently memorized:
1: [ 1]barkskin [ 1]create food [ 5]thorn spray
2: [ 3]cure light [ 1]refresh [ 1]sustenance
3: [ 2]elemental fist [ 2]fly
5: [ 1]cure serious

------------------------------------------
Code segment:
------------------------------------------

#trig trmem {^Spells currently memorized:$} {#var tmplist "";#var tmplist2 "";#temp {^$} {#state trmem 0}}
#cond {} {#additem tmplist %line} {looplines|param=99}
#ali strack {
#var tmplist2 "";
#loop %numitems(@tmplist) {
#additem tmplist2 %delete(@tmplist.%i,1,3)};
#var tmplist "";
#loop %numitems(@tmplist2) {
#var tmpvar @tmplist2.%i;
#var tmpcntr 0;#loop %numwords(@tmpvar) {
#add tmpcntr 1;#additem tmplist %word(@tmpvar,@tmpcntr)
}
};
#var tmplist2 "";
#var endlist "";
#loop %numitems(@tmplist) {
#if (%isnumber(%left(@tmplist.%i,1)) = 1) {
#additem endlist %left(@tmplist.%i,1)
}
}}

--------------------------------------------

My problem is that after I end up with the var tmplist holding: 1barkskin|1create|food|5thorn|spray|3cure|light|1refresh|1sustenance|2elemental|fist|2fly|1cure|serious
I'm trying to separate out the number of each spell with the if statement and then add it to the endlist. (When completed this would also add the separated spell words ie. elemental fist).
I'm expecting endlist to contain 1|1|5|3|1|1|2|2|1 but the final value is 1|5|3|2 which seems to indicate it's storing identical values in the same slot.

Any help would be greatly appreciated.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue May 13, 2003 2:48 pm   
 
The #ADDITEM command does not add duplicates, while the %additem functions does. Change your #ADDITEM commands to functions calls, example:
#VAR myList %additem("1", @myList)

Kjata
Reply with quote
kadath
Newbie


Joined: 07 May 2003
Posts: 2

PostPosted: Tue May 13, 2003 3:00 pm   
 
Thanks Kjata, fixed the problem right up.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net