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
Virus
Wanderer


Joined: 29 Jun 2002
Posts: 69
Location: USA

PostPosted: Sun Jul 21, 2002 12:44 am   

words()
 
Not sure if you guys are familiar with Mux coding or even Mu* coding in general, but there is a function called words() that returns the amount of word in a string, IE words(Are you there) will return 3, while words(there) returns 1. Is there a function similar to this in zmud? Heres my delema. I am making a damage trigger to track damage to locations and junk like that. Sometimes you can get hit in your Head or your Right Torso Rear). Ok, so maybe I make it like this...
%left( %word( %2, 1), 1)%left( %word( %2, 2), 1)%right( %left( %word( %2, 3), 2), 1)
but, what if I get something like Head (Rear)? See it works if the word rear only appears in the 3rd word, and if you dont get a 3rd word it works also, but what if the word (Rear) shows up in the second space. It kinda throws off the code. Now for the reason behind words().
I want to right code similar to %if( words(%2) = 3, %left( %word( %2, 1), 1)%left( %word( %2, 2), 1)%right( %left( %word( %2, 3), 2), 1))%if(words(%2) = 2,%left( %word( %2, 1), 1)%right( %left( %word( %2, 2), 2), 1))

Heres what it does, say %2 are the words Right Torso, it will return RT. If %2 is Right Torso (Rear), it will return RTR. Now, if I dont have a words() function I get the following if %2 is Head (Rear) H(. I want it to return HR. Get it?

Richard Powell
Mux Alias: Virus
2796 Wizard Staff
64.89.10.1 port 2796
Rich@gigdev.com
Reply with quote
Virus
Wanderer


Joined: 29 Jun 2002
Posts: 69
Location: USA

PostPosted: Sun Jul 21, 2002 1:07 am   
 
Never mind. I figure I am going to do the follwoing:

%left( %word( %2, 1), 1)%if( %2 = (Rear), %right( %left( %word( %2, 2), 2), 1), %left( %word( %2, 2), 1))%right( %left( %word( %2, 3), 2), 1)

I think this will work for what I need.

Richard Powell
Mux Alias: Virus
2796 Wizard Staff
64.89.10.1 port 2796
Rich@gigdev.com
Reply with quote
Virus
Wanderer


Joined: 29 Jun 2002
Posts: 69
Location: USA

PostPosted: Sun Jul 21, 2002 1:22 am   
 
Bah, its still not working. Heres the trigger pattern

You hit for (%d) points of damage to ({Head|Head (Rear)|Right Torso|Right Torso (Rear)})

What I want is I want the %2 to be a variable like HR for head (rear), H for head, RT for right torso, RTR for right torso rear and for some reason I am stumped. SOmeone pls help?

Richard Powell
Mux Alias: Virus
2796 Wizard Staff
64.89.10.1 port 2796
Rich@gigdev.com
Reply with quote
Drevarr
Beginner


Joined: 19 Dec 2001
Posts: 17
Location: USA

PostPosted: Sun Jul 21, 2002 1:42 am   
 
Based on your pattern: You hit for (%d) points of damage to ({Head|Head (Rear)|Right Torso|Right Torso (Rear)})

#VAR HIT_DAM %1
#VAR HIT_LOC %item(H|HR|RT|RTR,%ismember(%2,"Head|Head (Rear)|Right Torso|Right Torso (Rear)"))
#show @HIT_DAM @HIT_LOC

I get this output:
You hit for 500 points of damage to Right Torso (Rear).
500 RTR

Easier if you assign two variables with the stringlists of all the hit locations and the appropriate abbreviation for each in the same order.
Then you could have something like this:
#VAR HIT_LOC %item(@HitAbbr,%ismember(%2,@HitLocations))
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: Sun Jul 21, 2002 6:45 am   
 
The function you are looking for is %numwords().

This might be appropriate:

#VAR bodycode ""
#LOOP %numwords(%2) {#VAR bodycode %concat(@bodycode,%left(%word(%replace(%replace("%2",")",""),"(",""),%i)))}

Troubadour
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