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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Tex
Beginner


Joined: 16 Nov 2006
Posts: 21

PostPosted: Fri Feb 02, 2007 7:32 pm   

Need help understanding compatibility report
 
First of all this is a trigger from Zmud, its not really a sub but it adds info to a players classes.

trigger is as follows

Remort: (%*) $

replace_classes = ""
tier_classes = %1
tier_classes = %replace(@tier_classes," / ",|)
#FORALL @tier_classes {#FORALL @class_list {#IF %ismember(%i,@%j) {#ADDITEM replace_classes {%j~(%i~)}}}
replace_classes = %replace(@replace_classes,"|"," %ansi(grey)/%ansi(cyan) ")
#IF (@replace_classes = "") {} {#SUBSTITUTE {Remort~: %ansi(cyan)@replace_classes}}}

example mud output
Remort: Sage / Gladiator / Deacon
what i want it to display
Remort: Sage(Mage) / Gladiator(Warrior) / Deacon (Cleric)
or someting similar

Compatibility report tells me

Trigger Remort: (%*) $
Does not compile : unmatched parenthesis at row 2 col 32
%1 within quotes is not expanded [Help] : " tier_classes = %1 tier_classes = %replace(@tier_classes,"

Trying to understand the compatibility report, have tried lots of diffent changes to the trigger with no results

Thanks for any info
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Fri Feb 02, 2007 7:47 pm   
 
1. Don't use (%*) as your wildcard. Use (*) instead. This is a good practice in zMUD or CMUD.
2. The Compatibility Report isn't 100% infallible, especially when it comes to parsing double quotes. You can probably safely ignore the warning about %1 not being expanded. You might want to put double quotes around the | in the first %replace, however.
Reply with quote
Tex
Beginner


Joined: 16 Nov 2006
Posts: 21

PostPosted: Fri Feb 02, 2007 7:58 pm   
 
Adding the quotes to the Pipe ("|") allow sit to compile now but the trigger still isnt working..... Ideas?
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Feb 03, 2007 12:48 am   
 
You have a space character between the the ) and the $ in your trigger pattern. Is that intentional? Do your lines end with a space?
Reply with quote
Tex
Beginner


Joined: 16 Nov 2006
Posts: 21

PostPosted: Sat Feb 03, 2007 1:25 am   
 
yes there is a space after the last Class.
the trigger is fireing and the / is being replaced by the |
i know by putting some #say's in the trigger
the #forall is not adding to the list like i want it to
i have a variable lists like
#var class_list Warrior|Mage|Cleric|Thief|Psionicist|Paladin|Ranger
#var Warrior Gladiator|Armsmaster|Battlemaster|Warlord|Liege|Veteran|Champion|Savage|General
etc
the variable replace_classes is empty

trigger currently looks like
replace_classes = ""
tier_classes = %1
tier_classes = %replace(@tier_classes," / ","|")
#say @tier_classes
#FORALL @tier_classes {#FORALL @class_list {#IF %ismember(%i,@%j) {#ADDITEM replace_classes {%j~(%i~)}}}
replace_classes = %replace(@replace_classes,"|"," %ansi(grey)/%ansi(cyan) ")
#IF (@replace_classes = "") {} {#SUBSTITUTE {Remort~: %ansi(cyan)@replace_classes}}}

thanks for any help
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Feb 03, 2007 6:05 am   
 
Your script as it is at the moment is running the penultimate and final lines for every item in @tier_classes:

Code:
replace_classes = ""
tier_classes = %1
tier_classes = %replace(@tier_classes," / ","|")
#say @tier_classes
#FORALL @tier_classes {
  #FORALL @class_list {
    #IF %ismember(%i,@%j) {
      #ADDITEM replace_classes {%j~(%i~)}
    }
  }
  replace_classes = %replace(@replace_classes,"|"," %ansi(grey)/%ansi(cyan) ")
  #IF (@replace_classes = "") {} {
    #SUBSTITUTE {Remort~: %ansi(cyan)@replace_classes}
  }
}


Is that intended? Seems to me like the last %replace and #sub should only be run once. In addition, CMUD won't understand @%j, you need to change it to @{%j} to tell cmud explicitly that %j is the name of the variable. Finally, you'll get:

Code:
replace_classes = ""
tier_classes = %1
tier_classes = %replace(@tier_classes," / ","|")
#say @tier_classes
#FORALL @tier_classes {
  #FORALL @class_list {
    #IF %ismember(%i,@{%j}) {
      #ADDITEM replace_classes {%j~(%i~)}
    }
  }
}
replace_classes = %replace(@replace_classes,"|"," %ansi(grey)/%ansi(cyan) ")
#IF (@replace_classes = "") {} {#SUBSTITUTE {Remort~: %ansi(cyan)@replace_classes}}


Which is working fine in the tests I did.

It'll be nice when #additem works with local vars so you can get rid of @replace_classes.
Reply with quote
Tex
Beginner


Joined: 16 Nov 2006
Posts: 21

PostPosted: Sat Feb 03, 2007 8:08 am   
 
awesome it works !! u are right about the last replace and sub only need to be done once. not sure what got copied wrong cause my code looks like yours after i correct the @{%j}. I am gueesing i have to add the {} so cmud will evaluate %j?

thanks again for the help
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Feb 03, 2007 3:15 pm   
 
It'll actually evaluate %j fine, but it won't then evaluate the @whatever result so it'll be looing for %i in the literal string "@Warrior" or something which obviously won't ever match.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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