Creating triggers on the fly in Nexus?

I'm looking to build myself a player name highlighter that isn't wildly inefficient, and I can't seem to find any documentation on creating a new trigger and deleting existing ones via scripting. Is there documentation somewhere for this, or is it even possible via the official API? 

I can always just monkey patch the client object and try to replicate the existing reflex patterns there, but I'd rather not do that if there are official means available.

Answers

  • I haven't touched this in a while.. had good intentions when I started but this system might save you a lot of work if you want to pull from it and use anything from it.. lacks a few structural things that you are probably better than me at because I was relatively new to JavaScript and was using this as a learning tool

    https://github.com/jhuiAchaea/Nexsys
    image
  • @Jhui Thanks for the reference. Can you point out where in there you're creating new triggers on the fly?
  • I think in the highlighting stuff. If it's not included I might have to log in to my actual profile and figure out where I did it 
    image
  • AustereAustere Tennessee
    Jhui said:
    I think in the highlighting stuff. If it's not included I might have to log in to my actual profile and figure out where I did it 
    Someone should report this.  Pretty sure @Jhui doesn't login this late.  Obviously hacked account.



    (Hi Jhui) 
  • I realize I'm necro-ing this post, although there have been a few new ways to tackle this problem. By this problem I mean, highlighting adventurer names in larger blocks of text. 

    With the addition of Nexus Event triggers, you can use the onGMCP message or trigger line gained when a person enters the room, adding them to an array of names. Using a similar "Event trigger" for blocks of text, you can create a condition that allows for any names that are in a given array to be highlighted and rewritten within that blob on the main console. Although you will need to learn how to first separate blobs/strings of text into arrays of single words, and then cross reference them with your saved name list. 

    var words = 'never forget to empty your vacuum bags',
        wordArray = words.split(' ');
    
    console.log(wordArray); <span>// ["never", "forget", "to", "empty", "your", "vacuum", "bags"] </span>

    The other simpler option would be to create a script in onGMCP, that allows for targets who are dictated by in-room data; to be listed in a notice similar or at the end of our prompt. {Room.Players, Room.AddPlayer, Room.RemovePlayer} should be the correct incoming objects with all adventurer names.

    The benefit to doing it this way, is you can also filter your allies before showing the notice, allowing you to only see target-able enemies. Since you have the array of names at the ready, you can also make a keybind; that allows for the setting of each target in order; similar to the nexus' in-built "space+Tab to set adventurer target". Or you are able to simply re-target the next person when the first dies. Also having the names in the form of an array will allow you to shuffle, add to, or remove from, the kill order as you please. (Array functions are godly, splice, shift, unshift, push, etc.) https://www.w3schools.com/js/js_array_methods.asp

    • Example From Manual: Room.Players [{ "name": "Tecton", "fullname": "Tecton the Terraformer" }, {"name": "Cardan", "fullname": "Cardan, the Curious" }]

    Using this you will be able to have a list of target-able names, and if you are keen enough, the ability to target them by macro or using hyperlinks.
    I believe something like:
    • Room.Players.name = [namearray]; 
    • ((Manipulate how ever you want or not at all)); 
    • client.set_variable("inroom-enemy-name-array", namearray); 
    • client.print(namearray);
    Is the most simple method. 

    Regarding making triggers on the fly, I don't think it's possible to add/delete a trigger using in-built nexus functions. At best you can make triggers that have varied purposes and have them activate and deactivate as needed.

    This Nexsys system seems very well put together, although given how often the client updates; I don't know how difficult it is trying to keep active with a third party system. Is this system still working?
  • ZahanZahan Valhalla
    Ah hell might as well add to the necro since i'm loitering.  Might help someone someday.

    So, a name database... actually isn't that hard.  I had a working one built at one point but a CORS issue meant scrapping it.  A basic rundown of what I did - pulled the text from onBlock and split it into words.  Scrap every word that doesn't start with a capital letter then remove all symbols+text (like in Bob's fruit-tree).  That left me with all the proper nouns which I ran against a saved database (loaded into a javascript object pulled from a nexus variable).

    If it's in the database, it checks for city affiliation and then jquerys the html by surrounding the name with a colored span (don't forget to hit the scrollback buffer too).  Then, or if not, it pings the achaea character api on the website to update the database if needed or possible.  The thing to watch for here is those people who try to be crafty with hiding their city in the api, to which you can just trigger to honors them.  It worked pretty well actually and only would lag slightly when coloring QW which i could have fixed if the project survived.


    Enough about that, now about triggers.  The way nexus works is when you connect, it runs a script of all your stuff - settings, plugins, etc - which sets up the webpage in your browser that is the nexus client accordingly.  This means all your triggers and aliases and whatnots, are loaded by javascript, so you can make (or delete them) as you wish with the same javascript.  All the code for it is in the client already which you can get by saving the webpage (file>save-page-as or ctrl+s) and cracking open the js files. 

    Bonus: adding a trigger with script, just adds a trigger... to the webpage you have loaded.  It won't be there the next time you load nexus, unless you force a save settings to send that updated plugin info to the achaea settings server.  There is a simple function for this actually built already into nexus already, but i can't remember if it's in the client page code or the settings page code (probably the settings page).
    Click here for Nexus packages
    Currently available: Abs, Cnote, Keepalive, Lootpet, Mapmod
  • @Zahan Tecton fixed the CORS issue for the Name API a few months ago
    "All we have to decide is what to do with the time that is given to us."

  • ZahanZahan Valhalla
    @Tysandr Aye I remember that in the nexus discord channel.  Huge step forward. 

    Unfortunately, I had built my entire plugin to work around the CORS issue (which it did) and then they made the game server secure, which tanked the plugin.  Now you wouldn't need any of the long-winded workarounds I had to fuddle with - it would be much easier.
    Click here for Nexus packages
    Currently available: Abs, Cnote, Keepalive, Lootpet, Mapmod
Sign In or Register to comment.