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
harley
Apprentice


Joined: 05 Apr 2008
Posts: 121

PostPosted: Fri Oct 29, 2010 12:02 pm   

3.31// Script question
 
I think i've answered this myself, but it doesnt seem to be the best way.. maybe it is.
I have a var QuestMob
The current value is "laying goose"
If I wanted to pick only the first word in the value, ie. laying is there a simple solution?
my idea was
Code:
questmob = %replace(QuestMob, " ",|)

would that work and be efficient?

I havent tried it as i'm at work currently.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Oct 29, 2010 1:34 pm   
 
It does work. I have used similar replace functions to tokenize strings, letting me examine each word individually. Your statement would probably more like
Code:
questmob = %replace(@QuestMob, " ","|")

If you only want the first word, you could also do use something like %match(%trim(@questmob),"^(%w)",$firstword).
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Oct 29, 2010 2:41 pm   
 
Using %match() in this case would be far less efficient than %replace() or %word() (%word() is designed to let you retrieve individual words by position, given some sort of delimiter).
_________________
EDIT: I didn't like my old signature
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