[NEXUS] Enemying Script request

So, with my horrid attempts to cannibalize coding and failing horridly.

Does anyone have a quick and dirty way to enemy a list of people for Nexus?  Whether by following someones "MY ENEMIES ARE: <PERSON>, <PERSON2>, etc etc"  or just by an alias where I can copy/paste that list and it somehow gets rid of the ", " in each one.

I'd be super happy and cough up 5cr if someone could make a functioning one (and possibly show me the steps to do something similar)

Comments

  • edited February 2017
    Quick and dirty? If you have a variable that's a string containing the list of names, you could do this:
    var names = yourvariable.split(/[^A-Za-z]+/);
    
    names.forEach(function(name) {
    	send_direct("enemy " + name); // is this still how Nexus works?
    });
    

    Can't help you with making the actual alias or triggers, though, since I've never really used the Nexus client.

    EDIT: Changed the regular expression to split on so that it will match anything that's one or more non-letter characters (i.e. anything that's not A-Z or a-z), so you're not tied to a specific format for the list of names. More useful for an alias since you then don't have to type a comma, you can just separate each name by a space.


  • Antonius said:
    Quick and dirty? If you have a variable that's a string containing the list of names, you could do this:
    var names = yourvariable.split(/[^A-Za-z]+/);
    
    names.forEach(function(name) {
    	send_direct("enemy " + name); // is this still how Nexus works?
    });
    

    Can't help you with making the actual alias or triggers, though, since I've never really used the Nexus client.

    EDIT: Changed the regular expression to split on so that it will match anything that's one or more non-letter characters (i.e. anything that's not A-Z or a-z), so you're not tied to a specific format for the list of names. More useful for an alias since you then don't have to type a comma, you can just separate each name by a space.




    var names = args[1].split(/[A-Za-z]+/);
    
    for (let enemy of names){
          send_command("enemy " + enemy);
    }
    simple. :)

    2015/01/12 Tecton, the Terraformer has bestowed His divine favour upon you. It will last for approximately 1 Achaean month.
  • Well, I've got it working (???) for if it's one target using Valaria's (with a ^ from Antonius' in the [A-Za-z] bit.

    Hell, it gets the first target only, in all cases, even with numerous names.  The text that I'm operating off of is

    "My Enemies are: [Name1], [Name2], [Name3], etc..."

    What'd be the trigger/way to go about getting multiple people at once with that?
  • You need the list of names to be a single variable, so your regex needs to include everything after the colon in a single group. Something like this:

    "My Enemies are: (.+)\."$
  • Beep beep.

    It works now.  Thank ya!

  • [^a-z]
    Matches any characters except those in the range a-z.


    2015/01/12 Tecton, the Terraformer has bestowed His divine favour upon you. It will last for approximately 1 Achaean month.
  • AhmetAhmet Wherever I wanna be
    Including capitalized letters. Use \W instead
    Huh. Neat.
Sign In or Register to comment.