Nexus for noobs

i just wanted to kick off a discussion for those of us who are “JavaScript Challanged” and rely on simplified scripting in Nexus.  

Questions. Answers. Tips and tricks... everything goes. 

I’ll start with a question. How do you add a line break in Nexus “show text”? When I kill a mob, I’d like a reinforced message that breaks into several lines, but I can’t figure out how to break in in the input box. Thus far, I’ve tried /n and <br>, neither worked. Thoughts?
«1

Comments

  • MarunaMaruna Member Posts: 371 ✭✭✭
    edited December 2018
    Shouldn't it be \n? not /n. I hate javascript with a fiery passion, so just going off memory.
  • SephemSephem Member Posts: 25
    For anyone interested there is a good article on the Achaea forums titled "JavaScript for Nexus Newbies"
  • StarFiryStarFiry Member Posts: 32
    Maruna said:
    Shouldn't it be \n? not /n. I hate javascript with a fiery passion, so just going off memory.
    Maybe... I’ll give it a spin. Sephem said:
    For anyone interested there is a good article on the Achaea forums titled "JavaScript for Nexus Newbies"
    Do you happened to have a link?
  • TyeTye Member Posts: 127 ✭✭✭
    Link commented, waiting approval. @StarFiry

  • PoetPoet Member Posts: 122 ✭✭✭
    edited December 2018
    I couldn't make this work without scripting.  Here's the script though:

    //Multi-line Text Print
    display_notice("\n\nIT'S\n\nDEAD\n\n!!!!!!!!!!!!!!!!!\n\n", "red","black");

    Edit- Also, if you really want the text to stand out, reverse the colors. You can totally have black text on a red background.


    [Cassandra]: Poet will be unsurprised to learn that she has unread news.
  • SephemSephem Member Posts: 25
    StarFiry said:
    Maruna said:
    Shouldn't it be \n? not /n. I hate javascript with a fiery passion, so just going off memory.
    Maybe... I’ll give it a spin. Sephem said:
    For anyone interested there is a good article on the Achaea forums titled "JavaScript for Nexus Newbies"
    Do you happened to have a link?
    https://forums.achaea.com/discussion/4584/javascript-for-nexus-newbies-part-1
  • oldarkoldark Member Posts: 6
    tab cycles through available targets in the room and assigns to your target automatically. You can see the selected one in the mobs list that's default in the upper right.
  • MinionMinion Member Posts: 162 ✭✭✭
    I'm getting a ton of latency when I type in commands to nexus. Upwards of 3 seconds and then 3 sends once I hit enter for it to get into the game. All of my other keybinds work fairly well, still getting latency there but only up to 1.5-2 seconds. Suggestions?

    System is old (that's why I play MUDs and not graphical) and I'm using chrome.
  • StarFiryStarFiry Member Posts: 32
    Minion said:
    I'm getting a ton of latency when I type in commands to nexus. Upwards of 3 seconds and then 3 sends once I hit enter for it to get into the game. All of my other keybinds work fairly well, still getting latency there but only up to 1.5-2 seconds. Suggestions?

    System is old (that's why I play MUDs and not graphical) and I'm using chrome.
    What’s your ping is like?
  • MinionMinion Member Posts: 162 ✭✭✭
    StarFiry said:
    Minion said:
    I'm getting a ton of latency when I type in commands to nexus. Upwards of 3 seconds and then 3 sends once I hit enter for it to get into the game. All of my other keybinds work fairly well, still getting latency there but only up to 1.5-2 seconds. Suggestions?

    System is old (that's why I play MUDs and not graphical) and I'm using chrome.
    What’s your ping is like?
    As soon as I start typing it jumps from 200 to 2500.
  • StarFiryStarFiry Member Posts: 32
    Minion said:
    StarFiry said:
    Minion said:
    I'm getting a ton of latency when I type in commands to nexus. Upwards of 3 seconds and then 3 sends once I hit enter for it to get into the game. All of my other keybinds work fairly well, still getting latency there but only up to 1.5-2 seconds. Suggestions?

    System is old (that's why I play MUDs and not graphical) and I'm using chrome.
    What’s your ping is like?
    As soon as I start typing it jumps from 200 to 2500.
    Well, 2500 would explain it. I did notice some lag, but not that bad. Not sure if it’s nexus related though. 
  • MinionMinion Member Posts: 162 ✭✭✭
    I can run it on mudlet without any delay at all. 
  • EMDAEMDA Member Posts: 32
    I've done a lot of system work in Mudlet in the past, so I'm pretty familiar with lua and that general style of coding. I wanted to make something in Nexus this time so I can play from various computers a little more easily than the best ways to do that in Mudlet, but I feel like a total idiot when it comes to doing anything in the client. Could someone do a step-by-step on using the Linkify tool? The nexus wiki doesn't really address the various options it has and what should be a 5-second thing has been way more than that.

    The simple thing I wanted to do was make any occurrence of a non-named zone a clickable link to show its starchart. I made a regex trigger that catches easily enough, but when it comes to the match with and command part of the box I'm utterly lost. Depending on the options I can break it entirely, make the text it's triggering on not even show up at all, or become clickable links that do "starchart <x>" where <x> is one of various attempts to get it to reference the regex capture, or match, etc.

    Also is there any way to have ctrl/alt+button keybinds work, or is that a limitation of being in a browser? I can assign them in the settings page but pressing the combination in-game just defaults to the unmodified button if it has a keybind of its own.
  • YalauYalau Member Posts: 68 ✭✭
    In Nexus when you have a regex trigger, if the type you're using below is a command, use @1 or @2 etc. To find the matches.  If you're using a script or function type, it'll be args[1] I'm fairly certain.  Is that what you want?
  • StarFiryStarFiry Member Posts: 32
    Caliah said:
    I couldn't make this work without scripting.  Here's the script though:

    //Multi-line Text Print
    display_notice("\n\nIT'S\n\nDEAD\n\n!!!!!!!!!!!!!!!!!\n\n", "red","black");

    Edit- Also, if you really want the text to stand out, reverse the colors. You can totally have black text on a red background.


    This is awesome! Such a life saver for critical events that otherwise go unnoticed with everything else happening! Thank you!
  • KilpaKilpa Member Posts: 9
    EMDA said:
    [snip]
    Also is there any way to have ctrl/alt+button keybinds work, or is that a limitation of being in a browser? I can assign them in the settings page but pressing the combination in-game just defaults to the unmodified button if it has a keybind of its own.
    Yeah this one has me stumped too.
  • KirinKirin Member Posts: 98 ✭✭✭
    I'm reasonable with simple scripting. However, I cannot trigger anything off of the prompt. Any way to trigger a simplified script off GMCP without actually having to code in the onGMCP function?
  • SqueakumsSqueakums Member Posts: 230 ✭✭✭
    Is there a simple way to show health loss from damage done to me in Nexus? Or health gains from non-passive WW healing for that matter.

    I keep getting random health changes during spars (probably bleeding) without a message to go with them. I'd really like knowing how much each attack is whacking me for. 
  • IorwerthIorwerth Member, Moderator Posts: 18 Moderator
    edited December 2018
    Kirin said:
    I'm reasonable with simple scripting. However, I cannot trigger anything off of the prompt. Any way to trigger a simplified script off GMCP without actually having to code in the onGMCP function?

    Squeakums said:
    Is there a simple way to show health loss from damage done to me in Nexus? Or health gains from non-passive WW healing for that matter.

    I keep getting random health changes during spars (probably bleeding) without a message to go with them. I'd really like knowing how much each attack is whacking me for. 


     There is also the onBlock function. From the docs, "called upon receiving each text block, allowing you to perform manipulations on it, or kickstart functionality that you want to execute on every prompt". It's still a function, though, not simple scripting.

    https://nexus.ironrealms.com/Functions#Default_functions

    @Squeakums you could also use the onBlock function to keep track of health change.
  • EMDAEMDA Member Posts: 32
    @Yalau I've tried a couple things. This for example captures the zone names fine and makes them a clickable link (including the space afterward for some reason which is weird). But it links to "starchart @1" instead of expanding @1 to the zone. Changing the type from 'value' breaks the whole thing. I've fiddled with the different settings but haven't found the right combination just yet.
  • YalauYalau Member Posts: 68 ✭✭
    edited December 2018
    Here's a quick and dirty script for highlighting your currently targeted person in Red:

    It's set as Regular Expression matching type, and the Trigger text is: ^(.*)$
    Under Actions you want it to Execute Script: 

    var match=args[1];
    var target=get_variable("@tar");
    if(match.includes(target)) {
        colorize_current_line(match.indexOf(target), target.length, "red", "black");
    }

    This should work for anybody, but you need to make sure when you target someone that it's setting the @tar variable in Nexus (@set @tar @1 if you're using a custom targeting alias).  The only downside is that I can't figure out a better way of finding matches other than ^(.*)$ which can be VERY taxing computationally.  If anybody knows of a better way of capturing the name of your current target in text, I am all ears.  In mudlet I've seen it done using temporary triggers that match based on substring which I think could be faster but Nexus doesn't have a way of making temporary triggers.  
  • KilpaKilpa Member Posts: 9
    EMDA said:
    [snip] Also is there any way to have ctrl/alt+button keybinds work, or is that a limitation of being in a browser? I can assign them in the settings page but pressing the combination in-game just defaults to the unmodified button if it has a keybind of its own.
    Got it - you need to make an additional reflex package and make sure it's above the original numpad movement package. Put your keybind reflexes in there and Bob's your aunty
  • KixKix Member Posts: 25 ✭✭
    Kilpa said:
    EMDA said:
    [snip] Also is there any way to have ctrl/alt+button keybinds work, or is that a limitation of being in a browser? I can assign them in the settings page but pressing the combination in-game just defaults to the unmodified button if it has a keybind of its own.
    Got it - you need to make an additional reflex package and make sure it's above the original numpad movement package. Put your keybind reflexes in there and Bob's your aunty
    They mean that things like Ctrl +1 or Ctrl + 2 is system default command to move browser tabs and such.
  • SevrantSevrant Member Posts: 3
    edited December 2018
    I'm trying to write an alias that lets me pull a @destination variable to insert into my starchart alias if I have one set, otherwise I want it to just send the starchart command by itself. In Mudlet, it would have been send("starchart " .. (matches[2] or destination)) with something like ^ch(?: (.+))?$ as the alias but I can't figure out how to write this with the simple scripting of Nexus, or in Java if it's not possible with the simple scripting - so any help would be appreciated!
  • AtalkezAtalkez Member Posts: 59 ✭✭✭
    ^ch (.+)$ — regular expression

    —Execute a script
    send_command(“Starchart “ +args[1]+)

    Not sure how to incorporate the :? portion
  • AvymosAvymos Member Posts: 28
    @Atalkez using (?:.+) is the same as using (.+), except it wont actually capture that capture group as an argument, which is the exact opposite of what you want for an alias like that.
  • AtalkezAtalkez Member Posts: 59 ✭✭✭
    Yeah I knew that from Mudlet, didn’t know how to use it (if it’s the same then ok) for Nexus. I didn’t see why he needed it either, so didn’t think too hard on it.
  • SevrantSevrant Member Posts: 3
    edited December 2018
    That isn't quite working. I don't think I described what I was going for very well either.

    So, say I want to travel to Iota. I want to use my set destination alias 'dest Iota' to set @destination as Iota. That way, when I send my 'ch' alias, it sends 'starchart Iota.' If I haven't set @destination, I'd like 'ch' to just send 'starchart'

    The example I was given is returning the 'This is an invalid command' error because it isn't sending the alias at all, just 'ch.'

    Update: Changing it to:

    send_command("starchart " + [args[1]]); 

    makes it fire, though ideally I'd like for 'ch' to send 'starchart' without any arguments if I don't provide any and to have it pull that @destination variable if it exists. I figure this will be based on an if/else type deal like "if @destination = null then send starchart or send starchart with arguments else send starchart @destination" but I just can't figure out how to actually write that.
  • EMDAEMDA Member Posts: 32
    @Sevrant The variables in Nexus aren't exactly variables in the same way they usually are in Javascript, or anyway they're stored differently. You can get and manipulate them with the client.get_variable(name) and client.set_variable(name, value) functions to have them show up on the Variable tab and be accessible through the @ calling method in simplified scripting.

    That said the example in your last post doesn't actually require the alias you're setting up as far as I can tell since if you're checking if @destination exists and acting on that the 'ch' alias doesn't need to take any additional arguments. You could just make an exact match alias with the execute script: 

    const dest = get_variable('destination') || ''<br>if (dest) {send_command('starchart ' + dest)} else {send_command('starchart')};

    A simplified code version of this same alias would be:


    Both of these would require you to set your destination variable to an empty string when you didn't have an active destination in mind. However, without seeing the rest of your code it might be easier to fold it all into your destination alias. You could do something like this:

    TRIGGER MATCH: ^dest(?: (.+))?$<br>TRIGGER TYPE: Regular Expression<br><br>if (args[1]) {<br>    if (args[1].toLowerCase() == "clear") {<br>        set_variable('destination', "");<br>        display_notice("Destination cleared.");<br>    } else {<br>        set_variable('destination', args[1]);<br>        display_notice("Destination set to: " + get_variable('destination').toUpperCase());<br>        send_command("starchart " + get_variable('destination'));<br>    };<br>} else {<br>    const dest = get_variable('destination') || '';<br>    send_command("starchart " + dest);<br>};

    This way you can use 'dest clear' to empty out your destination, 'dest' to show a starchart of your local space or your target if destination has been set, and 'dest <sector>' to set a destination and see its starchart.


  • SevrantSevrant Member Posts: 3
    edited December 2018
    Thanks a ton @EMDA - your explanation and example were super helpful. My coding skills are rudimentary at best, but I was usually able to get Mudlet to do what I wanted it to by modifying other people's scripts and your example has already made it easier for me to code some other stuff I've been wanting to do :)
Sign In or Register to comment.