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
resinoid
Newbie


Joined: 02 Sep 2009
Posts: 3

PostPosted: Thu May 07, 2015 10:14 am   

Help with counting symbols
 
Hi all...I'm not very good at trigger coding and wondered if any of you could help me out. What i am trying to do is a simple addition of 5 different symbols in a line. There are a total of 20 spaces for the symbols....this is the example

[###########*________]

variables for this are:

# =5
@ =4
* =3
: =2
. = 1
_ = 0

So, the above example would be equal to 58%

If anyone can help it would be much apprecialted.....thanks
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu May 07, 2015 12:38 pm   
 
Based on your example all that needs to be counted are the number signs and the single character after them.
#REGEX {^[([#]*)(.)} {#SHOW {%eval(5*%len(%1)+%ismember(%2,".|:|*|@"))}}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
resinoid
Newbie


Joined: 02 Sep 2009
Posts: 3

PostPosted: Thu May 07, 2015 6:06 pm   
 
Thanks for the response. Is there a way to when looking at an item to give a percent next to the bracketed symbols. This is what it looks like:

The Paingiver's runes are glowing eerily: [###########*________]

And somehow when I look at the item it give a description:


The Paingiver's runes are glowing eerily: [###########*________] {58%}


Thanks again for the response, really appreciate the help
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun May 10, 2015 10:46 pm   
 
#REGEX {[([#]*)(.)[_]*(])$} {#PSUB {%concat("{",%eval(5*%len(%1)+%ismember(%2,".|:|*|@")),"}")} %eval(%word(%x3,2)+2)}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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