|
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Fri Mar 21, 2008 7:13 pm
capturing names |
When doing a WHO HERE command in Achaea I am sent a list of names sepparated with commas and spaces with my name at the end. I want to enemy the people on the list very quickly (except myself of course) It looks like this:
You see the following people here:
Name1, Name2, Name3, ...., Rolly
(*), Rolly is about all there is to trigger to and if I'm lucky I can get the last name on the list. Is there some easy way to capture the names to a list variable or even to a bunch of normal variables or simply to enemy them right off and not store them at all? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Mar 21, 2008 8:37 pm |
#trig {You see the following people here:} {}
#cond {*} {#forall %replace(%line,", ","|") {enemy %1}} |
|
|
|
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Fri Mar 21, 2008 11:20 pm |
Thanks for the help. I've never seen this before but it kind of makes sense to me. Since there is no actual work to be done to the trigger line, the first set empty braces make sense. However does this denote a blank line in the script body followed by the #cond command?
I've read all I can find on the #cond command and it sort of makes sense. It performs a task on the following line or lines as far as I can see. It looks like the %replace stuff gets rid of the commas and spaces and turns them into "|" pipe characters which makes the line into a sort of list variable which can be delt with using the #forall. It still does nothing though. I am probably missing something simple. |
|
|
|
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Fri Mar 21, 2008 11:27 pm |
Maybe i am missing somthing but it doesn't look like a variable is actually being created. Doesn't the #Forall command need to reference a variable of some sort?
|
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Sat Mar 22, 2008 12:17 am |
#FORALL requires a string list, which is what the scheme %replace(%line,", ","|") returns.
|
|
_________________ Sic itur ad astra. |
|
|
|
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Sat Mar 22, 2008 2:02 am |
I'm sorry but it still doesn't work.
|
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Sat Mar 22, 2008 2:15 am |
Try this:
Code: |
#TRIGGER {You see the following people here:}
#COND {*} {List = "";#CALL %vartype(List,4);$count = %numwords(%line,",")-1;#LOOP $count {#ADDITEM List %word(%line,%i,",")}} "" "WithinLines|Param=1"}
|
|
|
_________________ Sic itur ad astra. |
|
|
|
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Sat Mar 22, 2008 2:27 am |
There is one more right bracket than left. should another left one be added or remove a right?
|
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Sat Mar 22, 2008 2:30 am |
Yes, of course, sorry. Remove the right-most bracket.
|
|
_________________ Sic itur ad astra. |
|
|
|
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Sat Mar 22, 2008 2:47 am |
Still nothing.
|
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Sat Mar 22, 2008 2:56 am |
OK, Rolly. If what you gave us above is exactly what the MUD sends you, then the problem is fixed as follows:
Code: |
#TRIGGER {You see the following people here:}
#COND {*} {List = "";#CALL %vartype(List,4);$list = %replace(%line,", ",",");$count = %numwords,$line,",")-1;#LOOP $count {#ADDITEM List %word($line,%i,",")}} "" "WithinLines|Param=1"
|
Your separator is a blank and a comma, not just a comma. |
|
_________________ Sic itur ad astra. |
|
|
|
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Sat Mar 22, 2008 3:30 am |
Didn't work. I changed $list to $line and the changed the #replace functionand ended up with this but still won't compile...
#TRIGGER {You see the following people here:}
#COND {*} {List = "";#CALL %vartype(List,4);$list = %replace(%list,", ","|");$count = %numwords,$line,",")-1;#LOOP $count {#ADDITEM List %word($line,%i,",")}} "" "WithinLines|Param=1" |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Mar 22, 2008 3:47 am |
Rolly wrote: |
However does this denote a blank line in the script body followed by the #cond command? |
No. The #cond command is a separate, top-level command that creates trigger states, just like #trig creates triggers.
Rolly wrote: |
I'm sorry but it still doesn't work. |
I made a typo, sorry. Should've checked this thread sooner. What I meant was:
#trig {You see the following people here:} {}
#cond {*} {#forall %replace(%line,", ","|") {enemy %i}}
which is working absolutely fine with the text you gave. I used #say "You see the following people here:";#say "Name1, Name2, Name3, ...., Rolly" to test it. Presumably the game won't let you enemy yourself, but if it does and you don't want to, change the command inside the #forall loop from "enemy %i" to #if (%i!="Rolly") {enemy %i}
Next time, please be more specific than "it doesn't work" and maybe we'll spot something like this sooner :P |
|
|
|
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Sat Mar 22, 2008 1:03 pm |
Thanks for everything so far but I see no way of creating a #cond as a top line statement. I can create a trigger state under the trigger but that is a fuction and i don't get the choice of having anything else. I don't think that will help. So how do I get this part of it done? Please forgive my ignorance.
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Mar 22, 2008 2:24 pm |
The function thing I believe is a bug. Trigger states should only be triggers; button states should only be buttons, etc. I remember reading something about this somewhere, so it's possible it's still on the buglist.
As for multistate triggers in general, see their shiny new help file. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sat Mar 22, 2008 4:19 pm |
Uh I reported that and it is a bug in the 2.20 beta version. You shouldn't have any problem in 2.18 with creating new trigger states.
|
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Sat Mar 22, 2008 4:28 pm |
Other than the fact that if one causes the triggers to fire fast enough, they will bring CMUD down, they work as one would expect.
|
|
_________________ Sic itur ad astra. |
|
|
|
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Sat Mar 22, 2008 4:50 pm |
Thanks for your patience, I got it working!
|
|
|
|
|
|