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
morgair
Beginner


Joined: 10 Nov 2000
Posts: 24
Location: USA

PostPosted: Tue Jul 30, 2002 7:03 am   

removing parenthesis from strings
 
heres my problem im trying to make some trigs to calculate how many of each kind of potion i need to brew the sytanx from the mud i would recieve is...

A pouch of purple cloth contains:
a fireshield potion (27)
a blazeward potion (26)
a sanctuary potion (49)
a slink potion (9)
a protection potion (28)
a fly potion (4)
a valiance potion (8)
a demonskin potion (26)
a create spring potion (37)
an iceshield potion (48)
an antimagic shell potion (6)
a shadowform potion (12)
a shield potion (7)
a stone skin potion (6)

now what i want to do is assign just the numeric value to the variable so i can use math commands to calculate from a preset max number of each potion...like i have 27 fireshields but my variable fireshieldcur keeps popping up with a value of (27) i need the parenthesis removed from it...what ive been trying is using %replace but cant figure out what syntax i would need to do this as it doesnt recognize %p inside of the function...heres my trig so far
pattern
a fireshield potion (%*)
command
#IF (%1 = %null) {#VAR fireshieldcur 1} {#VAR fireshieldcur %replace(%1,%p,%null)}

the first part works if the (27) is not displayed it sets the value to 1...which would be correct. But if its not null i get (27) as the value of the variable...ive tried %remove as well doesnt seem to work

Morgair, Master of the Obvious
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Tue Jul 30, 2002 9:31 am   
 
Try

#trigger {a fireshield potion ~((%d)~)} {#var fireshieldcur %1}

The ~ used make it so zMUD doesn't interpret the outer parentheses as an argument in the pattern to put in %1 but as an actual part of MUD output. %d will only match number and the inner parentheses assign the number to %1.

That will put the number without parentheses in your variable but just to answer your question, to remove parenthesis from something with them, you would do something like:

%replace(%replace(@VariableWithParens,"(",%null),")",%null)



 - Charbal
Reply with quote
morgair
Beginner


Joined: 10 Nov 2000
Posts: 24
Location: USA

PostPosted: Tue Jul 30, 2002 10:03 am   
 
still didnt work...i use this sytax for the command line
#IF (%1 = %null) {#VAR fireshieldcur 1} {#VAR fireshieldcur %replace(%replace(%1,"(",%null,")",%null))}

i need the pattern to stay the same the list might display two ways
a fireshield potion
a fireshield potion (27)
patterns wont match if i do it with quoting the parenthesis...
the sytax you gave me returned the variable value of 27)

Morgair, Master of the Obvious
Reply with quote
morgair
Beginner


Joined: 10 Nov 2000
Posts: 24
Location: USA

PostPosted: Tue Jul 30, 2002 10:09 am   
 
#IF (%1 = %null) {#VAR fireshieldcur 1} {#VAR fireshieldcur %replace(%replace(%1,")",%null),"(",%null)}

played around with it this works...thanks

Morgair, Master of the Obvious
Reply with quote
zeroz
Newbie


Joined: 27 Jul 2002
Posts: 8
Location: USA

PostPosted: Tue Jul 30, 2002 5:39 pm   
 
Hello!

I had the same issue, and oddly enough zMUD reads parenthesis as punctuation!

You can use the %p wildcard to allow the trigger to work.

#TRIGGER {a fireshield potion %p(%d)%p} {#IF (!fireshieldcur) {#VAR fireshieldcur %1} {#ADD fireshieldcur %1}} 


Mind you, I'm not completely sure if the usage of the ADD command works like that. I haven't tried ;)
That should solve your trigger problem!


- Z
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jul 31, 2002 3:13 pm   
 
It appears you found a solution that works (replacing the parentheses with %null). Another solution is to use two triggers, using an end-anchor for the one without a number.
#TR {a fireshield potion$} {#VAR fireshieldcur 1}
#TR {a fireshield potion ~((%d)~)} {#VAR fireshieldcur %1}

LightBulb
Senior Member
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