|
noname@wilke.me Newbie
Joined: 23 Jul 2018 Posts: 9
|
Posted: 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 |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4702 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
noname@wilke.me Newbie
Joined: 23 Jul 2018 Posts: 9
|
Posted: Tue Oct 23, 2018 4:11 pm |
Thanks, works great :D
|
|
|
|
noname@wilke.me Newbie
Joined: 23 Jul 2018 Posts: 9
|
Posted: 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. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4702 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
|
|