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
daemoan.vermillious
Apprentice


Joined: 28 Feb 2009
Posts: 135
Location: Chico, Ca

PostPosted: Mon Mar 14, 2011 1:36 am   

adding to a variable list via trigger?
 
I have this example who list:

Code:
Immortal       |  .x[[D'Ilmater]]x.              Carmine      >GoOnI of EclipsE<
Immortal       |  -=Highlander=-                 Vermillion   Marshal of LoD
Avatar         |  ([Hound of Hell])              Drausean     the Don of COOL
Avatar         |  !~~!Abomination!~~!            Xedric       Alchem of LoD

I would like to add each name into a variable list i can set to cycle my target variable

Now, Iam Doing This CAuse Iam going to attempt to pk via nyko gamepad..... but i would like to tap a buttom and cycle thru targets.....

whats the best way of doing this if someone could assist me
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Mon Mar 14, 2011 3:22 am   
 
Immortal | .xD\'Ilmaterx. Carmine >GoOnI of EclipsE<
Immortal | -=Highlander=- Vermillion Marshal of LoD
Avatar | ([Hound of Hell]) Drausean the Don of COOL
Avatar | !~~!Abomination!~~! Xedric Alchem of LoD

I've color coded the different parts of the output you want to parse. If I understand what it is you'd like to do, you want to generate a list of the names, highlighted above in red.

I assume the green part is the organization that character belongs to. Can that be absolutely anything, or are there only a certain number of possible organizations? ie the bit I've colored blue in the example you gave us shows only the possibilities 'Immortal' and 'Avatar'. If the green bit can be absolutely anything, parsing the pattern is going to be difficult, but if there are only a few it should be pretty easy. If there are only a few, can you post all of the possibilities?
Reply with quote
daemoan.vermillious
Apprentice


Joined: 28 Feb 2009
Posts: 135
Location: Chico, Ca

PostPosted: Mon Mar 14, 2011 3:46 am   
 
Blue is Status Level and can be anything
Green Is Class and can be anything
Red is Name that i would like captured and added to a list
I use a Target: @target variable for targeting
With aliases like
kill @target
decap @target
i would like to have an alias button that can cycle people on the on the who into my @target list that i can
update everytime i time who

sorry slightly tipsy hope you understand
and thanks for taking the time to help me out
Reply with quote
daemoan.vermillious
Apprentice


Joined: 28 Feb 2009
Posts: 135
Location: Chico, Ca

PostPosted: Mon Mar 14, 2011 3:49 am   
 
on another not too, theres an undfined amount of spaces in between the class and name
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Mon Mar 14, 2011 8:36 am   
 
If every part of the output you see from a who list can be anything, it's going to be extremely difficult to isolate which part is the name.

If you can isolate which part is the name, then it's just a matter of using #ADDITEM %item() and %numitems() to generate your list and toggle through it. eg if you saw lines like:
John was one of the Beatles
Paul was one of the Beatles
George was one of the Beatles

You could make a trigger with the pattern: ^(%w) was one of the Beatles$
And the value: #ADDITEM Beatles %1
That will generate a variable with the name 'Beatles' and the value 'John|Paul|George'. That's how you would go about creating the sort of list you want, but in that example, the lines being parsed are very consistent. The problem with the who list you're giving us is that it's made up of multiple random elements (all the different colored bits) and any method I can think of to try to get a trigger to parse those elements in order to isolate just the red bit will be terribly inaccurate and prone to errors.

Is there any way to retrieve the names of characters, other than a who list like the one you've posted?

When you say:
daemoan.vermillious wrote:
on another not too, theres an undfined amount of spaces in between the class and name


Is it always more than one space, and is it that way so that when you view the who list on your mud, it's formatted so that the names all line up vertically? If either is true, that would make it much easier to isolate the name from the other random elements.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Mon Mar 14, 2011 3:43 pm   
 
I've put the original who list in code tags, you should find it easier to define a trigger now.
_________________
Taz :)
Reply with quote
daemoan.vermillious
Apprentice


Joined: 28 Feb 2009
Posts: 135
Location: Chico, Ca

PostPosted: Mon Mar 14, 2011 6:20 pm   
 
Im having the coder dude a status who list
however for the time being can i manually enter the names into the list
for my @target
I dont know how to make the #add or to make it cycle thru the list numericly and not randomly...

something like #alias loadscan "#additem target %1 %2 %3 %4 etc"

and just loadscan tom joe larry moe curly

then cyclescan alias th cycle thru them

atleast till the new who gets put in
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Mar 14, 2011 7:59 pm   
 
#alias loadscan {#forall (%params) {#additem target %i}}
#alias cyclescan {#forall (@target) {kill %i;<etc>}
Reply with quote
daemoan.vermillious
Apprentice


Joined: 28 Feb 2009
Posts: 135
Location: Chico, Ca

PostPosted: Mon Mar 14, 2011 8:22 pm   
 
#alias cyclescan {#forall (@target) {kill %i;<etc>}
#alias cyclescan {#forall (@target) {kill %i}

it says both of these are invalid
and loadscan is only adding the individual names in value one and not value 1 2 3
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Mon Mar 14, 2011 9:27 pm   
 
Taz wrote:
I've put the original who list in code tags, you should find it easier to define a trigger now.

Perfect! <3

Try this daemoan:
Code:
<cmud>
  <class name="Targetting">
    <trigger priority="30">
      <pattern>^%x%s|  *  %s(%w)</pattern>
      <value>#ADDITEM AllTargets %1</value>
    </trigger>
    <var name="Target"/>
    <func name="NextTarget" >
      <value>$a = %ismember( @Target, @AllTargets)
#IF ($a = %numitems( @AllTargets)) {Target = %item( @AllTargets, 1)} {Target = %item( @AllTargets, ($a + 1))}
#SAY Now targetting @Target</value>
    </func>
    <var name="AllTargets" type="StringList">
      <json>[]</json>
    </var>
  </class>
</cmud>


Then put the line: #CALL @NextTarget() in to a macro for the button you want to press in order to cycle through your targets.

After showing the trigger your who list @AllTargets should contain the list "Carmine|Vermillion|Drausean|Xedric"
After that, when I hit the the macro a few times I get the output:
Now targetting Carmine
Now targetting Vermillion
Now targetting Drausean
Now targetting Xedric
Now targetting Carmine
Now targetting Vermillion

The variable @Target will be set accordingly.
Reply with quote
daemoan.vermillious
Apprentice


Joined: 28 Feb 2009
Posts: 135
Location: Chico, Ca

PostPosted: Mon Mar 14, 2011 9:43 pm   
 
whats the
<json>[]</json> ?

and can i just paste that into my code section and it will input last time i did something like that it currputed my session file and i lost everything...
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Mon Mar 14, 2011 10:41 pm   
 
<json> is a variable standard introduced one or two versions back. It's my understanding that all Cmud variables are now json compliant.
In this snippit of code, that line doesn't actually do anything, it's just generated by the XML parser.

The easiest way to import that snippit of XML code would be to highlight it by click+dragging your mouse, copying it to the clipboard by right clicking and selecting copy or pressing Ctrl+C, then going in to the Cmud package editor by pressing Ctrl+G, selecting your main window, right clicking on it and selecting paste, Like so:


If you have Cmud 3.33, this should not do anything that could corrupt your session.
Reply with quote
daemoan.vermillious
Apprentice


Joined: 28 Feb 2009
Posts: 135
Location: Chico, Ca

PostPosted: Mon Mar 14, 2011 11:08 pm   
 
Great Thanks For The Help, Is There Something I can Add In There To Exclude A List of names, such as clan members admin coders etc.
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Mon Mar 14, 2011 11:22 pm   
 
No problem :) And yes, that can be done too. How do you know which characters are clan members, admin and coders?

You can either filter them out with the trigger itself by making sure they never get placed in the list in the first place by the #ADDITEM AllTargets %1 line or you can filter them out later by running through a second list with code something like:

#VAR NotToTarget {DraxDrax|Rahab|Taz|Vermillion}
#FORALL @NotToTarget {#DELITEM AllTargets %i}

That will remove Vermillion from the list AllTargets and not do anything with DraxDrax, Rahab and Taz, since they're not part of that list.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Mar 15, 2011 12:44 pm   
 
Sorry, the reason my code didn't work earlier is because they were missing a final }
Reply with quote
daemoan.vermillious
Apprentice


Joined: 28 Feb 2009
Posts: 135
Location: Chico, Ca

PostPosted: Wed Mar 16, 2011 2:03 am   
 
is there a way to reset the target list it only seems to be adding anyone that wasnt already added to the list
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Wed Mar 16, 2011 8:47 am   
 
AllTargets = %null

That will reset the list of possible targets. Put that line in an alias or trigger to have the list reset automatically before names are added by the trigger which takes names from the who list.
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