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
noname@wilke.me
Newbie


Joined: 23 Jul 2018
Posts: 9

PostPosted: Mon Oct 22, 2018 5:53 pm   

Capture names as strings in list
 
Hi!
Im trying to capture my online friends to a String list. When typing a command to show who of my friends that are online I get something like this:


Friends Online: Name1 Name2 Name3 Name4 Name5 etc etc etc


So my friends are shown with a space, but I don't manage to capture the names one by one and add them to my list, I only manage to capture them all in one line which is not what I want since I want to be able to add and remove friends as they log on and log off (which gives me a simple message which I easliy managed to trigger on).

Cheers
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Mon Oct 22, 2018 9:27 pm   
 
#TRIGGER {Friends Online: (*)} {#FORALL %replace(%1, " ", "|") {#ADDITEM friendList %i}}

That should do it, enter it on the command line
_________________
Discord: Shalimarwildcat
Reply with quote
noname@wilke.me
Newbie


Joined: 23 Jul 2018
Posts: 9

PostPosted: Tue Oct 23, 2018 4:11 pm   
 
Thanks, works great :D
Reply with quote
noname@wilke.me
Newbie


Joined: 23 Jul 2018
Posts: 9

PostPosted: Tue Oct 23, 2018 4:43 pm   
 
Now, next problem is that when typing the command to show the friends online, the names are displayd with (F) directly after their names like this:

Friends Online: Pete(F) Pote(F) Charlie(F)

I have succesfully captured their names to a list with you trigger above, and the (F) is included after their names, but when a friend logs on or off the following outputs are shown:

Pete enters the game

and

Pete leaves the game

I also want to capture or remove their names from the list as they log on/off, but the (F) above makes it hard to acomplish.


I use the following code to capture names to the list on logon:

~[%3 enters the game]

#ADDITEM friendList %3
#VAR friendList %sort( @friendList)

But as stated above, there will be no (F) afterwards making it hard to remove the name from the list once they log off.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Tue Oct 23, 2018 6:54 pm   
 
this is actually easier to do that it looks
all you have to do is nest a second %replace function
The first one turned it into a string list, the second can strip out the unneeded stuff with a null replacement value

%replace(%replace(%1, " ", "|"), "(F)")
_________________
Discord: Shalimarwildcat
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