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

Nexus Documentation!

Solaine
Solaine Member Posts: 1

Nexus documentation!

Since Mudlet has oodles of documentation and Nexus has next to nothing, here's a bunch of things I know about Nexus. Hope this helps you all out! Be it a veteran Nexus user (stay strong guys) or a new player on the field. Please feel free to add your own findings onto this and let me know if you have any questions at all! 

I'll start this off with the really simple stuff, and work my way up to the really advanced things. Start wherever you feel comfortable.

THE BASICS

PACKAGES are your friend! Keep everything organized and capitals matter! 'Reflex packages' tab to manage them. 
GROUPS are a great way to keep all of your stuff organized. Recommended! Especially useful if you need to mass enable/disable certain code for certain things.
ALIASES are what you type in to the actual game that can execute any number of things.
KEYBINDS are a set combination of key-presses that will execute just like an alias would.
TRIGGERS are how you tell the game to respond to certain inputs. Be it an exact string of words, anytime you see a certain instance, or a super complicated regular expression.
EVENTS are certain types of thing that happen (moved rooms, someone enters your room, etc.)
FUNCTIONS are a way to store neat bundles of code in one place, and these can be called (executed) through aliases, functions, triggers, etc. 

VARIABLES AND OBJECTS

Variables are great, but try not to use tons and tons of them as they do take up space. Here's a tip! Get in the habit of deleting variables when you don't need them, or when they definitely won't be in use. More commonly, instead of always doing let variable = true and let variable = false do let variable = true and delete variable when saving them globally (locally doesn't much matter). 

Speaking of globally! To store a global variable using Nexus, you 
set_variable("variableName", value)
and to retrieve it you
get_variable("variableName")
The second parameter can be numbers or Boolean outside of quotes, and strings must be inside of quotes. Deleting works with
delete_variable("variableName")

I periodically like to go through my Variables list, since there's a whole tab for it, and often find a bunch of variables I can clear out that I haven't used in a while. It's a great way to help free up space.

As to objects, the best way to globally store and access these is using JSON. 
let obj = {
    key: "value1",
    keyTwo: "value2"
}

set_variable("obj", JSON.stringify(obj));
And to retrieve that:
let obj = JSON.parse(get_variable("obj"));

FUNCTIONS

Functions! Simplified scripting allows you to run functions within the same package, but if you're trying to run a function in a different package, you'll need to 'Execute script' for that. To do so is actually very easy.  Keep in mind that both names are case sensitive!
run_function("functionName", false, "Package name");

REFLEXES

REFLEX is a sort of catch-all word for nearly everything that's in your Nexus settings and code, and a great IC term to refer to things. To enable and disable reflexes, I've found this to be most efficient:
let reflex = reflex_find_by_name("Group", "Enable/disable", true, false, "Bashing")
reflex_enable(reflex);
reflex_disable(reflex);
This is an actual example I've used to enable and disable a large group of code for my auto-bashing package. 
- "Group" refers to the fact that it's a group (other valid parameters are "Trigger", "Alias", and "Function")
- "Enable/disable" is the case-sensitive name of the group I'm referring to
- true refers to the fact that it is case-sensitive and false would render that the opposite
- false means I'm looking at ALL groups regardless of if they're already enabled or not and true would be more selective
- "Bashing" is the name of the package this is in

STRING REPLACEMENT

Replacement can be super useful but is also fairly tricky to get going. Each instance often takes some trial and error so here's an example that is very useful:

Trigger text: A sigil in the shape of a small, rectangular monolith is on the ground\.
const index = current_line.parsed_line.text().indexOf(args[0]);
replace_current_line(index, args[0].length, " MONO ", '#8a8986', '#000000');
Note that the trigger text has to be in regular expression form for this to work. You CAN'T put ^ and $ because you want this to trigger in large paragraphs of room descriptions containing a monolith sigil to work. Index refers to where in the paragraph this line occurs, the next parameter refers to the length of the text I'm trying to replace, " MONO " is what to replace it with, and the following parameters are the fgcolour and bgcolour. 

MORE NEXUS BASICS

More things like this exist such as highlighting, gagging,  buttons, etc. The link is:

Some helpful hints:
  - client.print("Text", fgcolour, bgcolour) will NOT provide another line afterwards regardless of if it's inputted and display_notice("Text", fgcolour, bgcolour) will.
  - colorize_current_line and replace_current_line use regular expression inputs for their starting parameter. 0 would be the very first character that appears (whitespace included) and args[0].length is a good parameter for length in almost every instance
  - Button manipulation is great if you hunt a lot in different classes.

Some great websites:
  - https://www.rexegg.com/regex-quickstart.html [ A regular expression cheat sheet ]
  - https://regexr.com/ [ A regular expression tester, extremely useful! ]
  - https://beautifier.io/ [ Beautify JSON code which helps dissect large segments of GMCP ]
  - https://jshint.com/ [ JS validator: check if your JS code has proper syntax ]
  - You can Google 'colour picker' for hex codes, which are valid inputs as fg and bgcolour for client.print, display_notice, colorize_current_line, etc. 

FUNCTIONS AND DOCUMENTATION LINKS

-- main package-- : The built-in package Nexus gives you for storing everything. You can add more in the 'Reflex Packages' tab.

onLoad: A built-in Nexus function that runs every time you log in or sometimes when you come back from a disconnect. These are great to use for setting up all your defenses and resetting anything that might've stayed active when you qq'd

onGMCP: Mostly used to check for certain GMCP information (we'll get to that!) but can also be used to frequently check for something specific since the onGMCP function automatically ticks every second or so

GMCP: GMCP is a set of documentation that tells all about your character. This includes things like your name, age, race, class and class-specific information, your current room and area, the speaking channels you have access to (city, House, Order, clans, etc), and a plethora of other information. Here's all the documentation urls I have on GMCP that I reference frequently

[ Nexus documentation on IRE. This mostly tells you how to access certain parts of GMCP and what it'll actually show up as: an object, an array, a value, etc ]

[ 14 page PDF file detailing specifically CORE and IRE parts of GMCP ]
[ Namely good for Character, Room, Area, and Rift information ]

[ Very, very basic documentation that shows you essentially how to start using GMCP in your code ]

GMCP 

The specifics of GMCP! Here are some code examples within onGMCP funcitons and we can break down each one. 

if (args.gmcp_method == "Room.Info") {
    let room = args.gmcp_args.name;
    let area = args.gmcp_args.area;
    set_variable("currentArea", area);
    set_variable("currentRoom", room);
}
Essentially, if the method that GMCP is ticking on (args.gmcp_method) is the Room Information (Room.Info), let's pull the specifics of that information. Let's zoom in on the name and area parts (using dot notation since they show up as objects). Save them, and done!

if (args.gmcp_method == "Room.Info") {
    set_variable('roomEnvironment', args.gmcp_args.environment);
}
Does the same as the above, but specifically for the environment. Useful for harvesting and extracting scripts. 

if (args.gmcp_method == "Char.Items.List") {
    let mobs = args.gmcp_args.items.filter(e => e.attrib == 'm') || [];
    set_variable("mobs", mobs)
}
Here's another I used in my bashing package. This one looks at the items that are in my current room. The reason I'm filtering is so that I can look at only the things in the room with the 'm' attribute (monsters that are killable!). Since this can be such a large object, filtering is very useful in this particular case. 

if (args.gmcp_method == "Char.Vitals") {
    let rage = parseInt(args.gmcp_args.charstats[1].substring(6));
    set_variable("rage", rage);
}
This one pulls my rage value! Note that args.gmcp_method remains the same through essentially every GMCP function that you'll have and often to access various parts of these objects, you only need to dot notate the particular key value you're searching for. This is why the documentation above is so helpful because it tells you exactly what that'd look like. 

Finally, rift requests are a little tricky as you need to actually tell GMCP to request the information, since this isn't on the normal ticks. To do so:
send_GMCP("IRE.Rift.Request");
Then you would access the rift itself (inside of an onGMCP function) with:
if (args.gmcp_method == 'IRE.Rift.List') {
    let rift = args.gmcp_args;
    set_variable("rift", JSON.stringify(rift))
}
This is displayed as an object, with the keys being the actual rift items (sileris, red clay, etc.) and the values being the amount. If you don't have an item in your rift, it doesn't exist in the object. 

MISCALLENEOUS

That's the really hard stuff! If you're interested in simple scripting, this is your site:

And advanced scripting:

If you're interested in advanced scripting, you're more often than not going to change the `Send a command` dropdown to the very last 'Execute script' instead. JSON.stringify (briefly mentioned above in 'Variables and Objects') is also a great way to look at the full extent of your personal GMCP information. Which you can do with:
display_notice(JSON.stringify(GMCP), 'gold')
Be careful! This is gonna give you a huge output of information.

NEXUS PACKAGES

A forum post that links to a wonderful Character DB for specifically Nexus.

A Github link for a defense system. Also has neat features for things like bombs and sigils. 

https://github.com/goldrose51/Nexus-Mapper
Couldn't find the original so I made an attempt at putting it in a Github: here's a great mapper and way to edit the existing map with room-finder and walk-to features.

UI DOCUMENTATION 

The UI documentation link was initially a dropbox and seems to have since been deleted. If you're interested in this at all, please message me oocly and I can send you a download of the package I currently have, and walk you through how to build your own.
----

And that's it! I hope this helps you in your Nexus endeavors. Even though it can be really frustrating sometimes, hang in there! It becomes worth it once it all comes together, I swear. Any questions, or want help on Nexus, or help on some code? Please ask me! I love helping, and I'm available to talk oocly through messages or in discord. 
AelynAekaArgwinChubbsTorrentRomaenSpheraAtul

Comments

  • Argwin
    Argwin Member Posts: 84 ✭✭ - Stalwart
    Random tip, you can add WINDOW before any command to make the results display in a dialog window.
    AelynSolaine
Sign In to Comment.