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


Joined: 22 Oct 2000
Posts: 90
Location: Sweden

PostPosted: Wed Dec 19, 2001 4:12 pm   

Converting a string to an array
 
"Greetings y'all! And welcome all ye dang foreigners from other nations! Dear Lord, please be with our guests and prepare them for the butt-whoopin' they're about to recieve!"
-Opening speech of the Salt Lake City Winter Olympics?

Anyway, back to reality (?) I've returned to find out how to write an alias that interprets this:

gc cloak, silver necklace, bright ring, mithril chainmail

and creates a
#VAR gear {cloak|silver necklace|bright ring|mithril chainmail}
(or whatever items i choose to try to get)


"May the Force be with you"
[url]peewee@mars11.net[/url]
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Wed Dec 19, 2001 4:38 pm   
 
%replace will do exactly what you want:

#ALIAS gc {#VAR gear %replace("%-1", ", ", "|")}

Kjata
Reply with quote
peewee
Wanderer


Joined: 22 Oct 2000
Posts: 90
Location: Sweden

PostPosted: Thu Dec 20, 2001 2:34 am   
 
Thanks! I added my new knowledge together with another question I had to create a new alias:

#ALIAS gc
{
#VAR gear %replace("%-1", ", ", "|")
#VAR gear %replace(@gear,",","|")
open chest
#FORALL @gear {get %i from chest}
close chest
}

So now I give the command:
gc ring, chainmail, sack, jar, skulls
to recieve:
open chest

get ring from chest
get chainmail from chest
get sack from chest
get jar from chest
get skulls from chest
close chest
And the second %replace makes sure it doesn't matter whether I use a space after the commas or not... My thanks!


"May the Force be with you"
[url]peewee@mars11.net[/url]
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