Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

[NEXUS] Enemying Script request

FrederichFrederich Posts: 1,228Member @ - Epic Achaean
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

  • AntoniusAntonius Posts: 4,114Member @@ - Legendary Achaean
    edited February 16
    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.


  • ValariaValaria Posts: 385Member ✭✭✭ - Distinguished
    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.
  • FrederichFrederich Posts: 1,228Member @ - Epic Achaean
    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?
  • AntoniusAntonius Posts: 4,114Member @@ - Legendary Achaean
    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: (.+)\."$
    Frederich
  • FrederichFrederich Posts: 1,228Member @ - Epic Achaean
    Beep beep.

    It works now.  Thank ya!
    Valaria
  • ValariaValaria Posts: 385Member ✭✭✭ - Distinguished

    [^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 bePosts: 3,244Member @@ - Legendary Achaean
    Including capitalized letters. Use \W instead
    Huh. Neat.
    Valaria
Sign In to Comment.