Nexus Miniscripts

13»

Comments

  • RocketCatRocketCat Posts: 89Member ✭✭✭
    An actual MINIscript. Pretty simple vitals tracker, mainly being used for testing numbers for PvP. Should detect your class just fine.

    VIT <ON/OFF> - turns it on
    VIT TELL <PERSON/OFF> - tell the changes in your vitals to a friend who is probably beating you up.

    https://raw.githubusercontent.com/RocketCatIRE/Nexus/master/vit.nxs

    Hi, I'm Ata. Oh and maybe some other people, too. o:) Check out my various packages for Nexus: Vuu combat system, Global Pathfinder, Slicer Tools, Ship compass, JS from command line, and Vitals Tracker.
    tysandrPoetMatlkael
  • RocketCatRocketCat Posts: 89Member ✭✭✭
    Another miniscript. I'm on a laptop without a numpad so piloting is a pain in the arse. This package provides SHIP functionality your Nexus compass. It will automatically convert the compass when you SHIP BOARD/SHIP DISEMBARK.

    The compass buttons:
    directions: SHIP TURN <dir>
    in - SHIP DOCK
    out - SHIP LAUNCH
    look - SHIP BEACON
    up - SHIP THRUST FULL
    down - SHIP  MAXSPEED 10

    Hi, I'm Ata. Oh and maybe some other people, too. o:) Check out my various packages for Nexus: Vuu combat system, Global Pathfinder, Slicer Tools, Ship compass, JS from command line, and Vitals Tracker.
    KestreltysandrPeiry
  • Opt1kalOpt1kal Posts: 7Member
    tysandr said:
    Opt1kal said:
    Hey @tysandr - Wondering if you could throw together a defup command by chance for Nanoseer. This is really my first time messing with Nexus, and the last time I had a defup command was about a year ago in Lusternia...lol
    Think you sorted this out on Discord, care to share your script for others? :)

    Yeah, I did...lol. I've been hooked into World of Tanks this past week or so...I need to hop back on and make sure it's all smooth. I know there's still some hiccupery going on that I'll need to iron out.
  • MigiMigi Posts: 18Member
    Opt1kal said:
    tysandr said:
    Opt1kal said:
    Hey @tysandr - Wondering if you could throw together a defup command by chance for Nanoseer. This is really my first time messing with Nexus, and the last time I had a defup command was about a year ago in Lusternia...lol
    Think you sorted this out on Discord, care to share your script for others? :)

    Yeah, I did...lol. I've been hooked into World of Tanks this past week or so...I need to hop back on and make sure it's all smooth. I know there's still some hiccupery going on that I'll need to iron out.
    Noooo... play War Thunder instead.
  • PoetPoet Posts: 64Member ✭✭
    So if you are an old head like me, height expressed in centimetres doesn't mean very much. If you want to see it in feet and inches when you look at someone-

    Trigger regex:
    ^Height:\s+(\d+) cm$
    //Replace height script
    
    imperial=toFeet(args[1])
    replace_current_line("18", "6", ""+imperial, "#b3b3b3", "black");
    
    function toFeet(n) {
      var realFeet = ((n*0.393700) / 12);
      var feet = Math.floor(realFeet);
      var inches = Math.round((realFeet - feet) * 12);
      return feet + "&prime; " + inches + '&Prime;';
    }
    

    [Cassandra]: Poet will be unsurprised to learn that she has unread news.
    tysandr
  • tysandrtysandr Posts: 90Member ✭✭✭
    edited February 12
    Pretty excited about this so wanna share it early, please write back with errors & things... v0.01 of simple HTML to Nexus' chunk writing:

    vparser = function(str) {
     var out = []; 
     var str = str || "<span id='e' class='xc-blue'>v</span><span class='xc-violet'>thing<span id='d' class='xc-red'>asdf</span>c</span>"; // sample line
     var RE = /(<span|<\/span>)/g; 
    
     var matches; 
     while (matches = RE.exec(str)) { out.push(matches.index) }; 
     // console.log(out); 
     var cap = str.length
     var g = []
     for (var i = out.length - 1; i > -1; i--) { 
      var n = out[i]
      g.unshift(str.substring(n, cap))
      cap = n
     }
     // console.log(str); console.log(g)
    
     var cm  = []
     var chunks = []
     for (var i = 0; i < g.length; i++) {
      var el = g[i]
      if (el.match(/\<\/span\>$/)) {
        cm.pop()
        var c = cm[cm.length - 1] || 'reset'
        chunks.push( client.linechunk_color(c) )
      } else if (el.match('</span>')) {
        cm.pop()
        var c = cm[cm.length - 1] || 'reset'
        chunks.push( client.linechunk_color(c) )
        var e = el.replace('</span>','')
        chunks.push( client.linechunk_text(e) )
      } else if (el.match('<span ')) {
        // console.log('new span ' + el)   
        var c = el.match(/\xc-(\w+)/)
        if (c) {
         cm.push(c[1])
         chunks.push( client.linechunk_color(c[1]) ) }
        var e = el.replace(/\<span.*?\>/,'')
        chunks.push( client.linechunk_text(e) )
      }
     }
     // console.log(chunks)
     return chunks
    }

    Used in a trigger:
      if (client.current_block) {
        var idx = client.current_block.indexOf(client.current_line) - 1
        if (idx < 0) { idx = 0 }
        
        // Step backwards until we find an ungagged line
        for (var i = idx; i > -1; i--) {
          if (typeof client.current_block[i] != 'undefined' && client.current_block[i].gag != true) {
            var m = vparser("<span class='xc-grey'>-<span class='xc-red'>" + value + "</span></span>")
            client.current_block[i].parsed_line.chunks = client.current_block[i].parsed_line.chunks.concat(m)
            break;
          }
        }
      }
    

    Use with <span class='xc-color'>message</span>.
    vote ∘ Explore Nexus mods for Starmourn & Achaeandb for Nexus

    Poet
  • RocketCatRocketCat Posts: 89Member ✭✭✭
    Get those prompts to show up on your logs. Let's make a few tweaks to generate_text_block. Put this in onLoad:
    client.generate_text_block = function(lines) {
        var count = 0;
    
        var timestamp;
        if (client.show_timestamp_milliseconds === true)
            timestamp = client.getTimeMS();
        else
            timestamp = client.getTimeNoMS();
        var cl = "timestamp mono no_out";
        timestamp = "<span class=\"" + cl + "\">" + timestamp + "&nbsp;</span>";
    
        var res = '';
    
        var counter = 0;
        for (var i = 0; i < lines.length; ++i) {
            var txt = lines[i].parsed_line;
            var font = lines[i].monospace ? 'mono' : '';
            var line = "<div class=\"" + font + "\">" + timestamp + (txt ? txt.formatted() : '') + "</div>";
    
            // we want gagged lines to be logged, too
            if (logging && txt) append_to_log(line);
    
            if (lines[i].gag) continue;
            counter++;
    
            if (txt) {
                count++;
                res += line;
            }
            var pr = lines[i].parsed_prompt;
            if (pr && (count > 0)) {   // no prompt if we gagged everything
                var my_prompt = "<div class=\"" + font + "\">" + timestamp + pr.formatted() + "</div>";
                res += my_prompt
                if (logging) append_to_log(my_prompt);
            }
            // empty line - include it if it's neither the first nor the last one
            // using "counter" instead of "i" fixes problems where the empty line is included after channel markers and such
            if ((!pr) && (!txt) && (counter > 1) && (i < lines.length - 1)) {
                res += '<div line>' + timestamp + '&nbsp;' + '</div>';
            }
        }
        if (client.extra_break && res.length) res += "<br />";
        return res;
    }
    
    Hi, I'm Ata. Oh and maybe some other people, too. o:) Check out my various packages for Nexus: Vuu combat system, Global Pathfinder, Slicer Tools, Ship compass, JS from command line, and Vitals Tracker.
    tysandr
  • KestrelKestrel Posts: 321Member ✭✭✭✭
    @RocketCat is there any way to make it so that only emotes and say commands show up in logs?

    "I'll take care of it, Luke said. And because he said it instead of her, I knew he meant kill. That is what you have to do before you kill, I thought. You have to create an it, where none was before."
    — Margaret Atwood
  • RocketCatRocketCat Posts: 89Member ✭✭✭
    Kestrel said:
    @RocketCat is there any way to make it so that only emotes and say commands show up in logs?
    Would probably be a bit convoluted... but theoretically yes. Ill look into it.
    Hi, I'm Ata. Oh and maybe some other people, too. o:) Check out my various packages for Nexus: Vuu combat system, Global Pathfinder, Slicer Tools, Ship compass, JS from command line, and Vitals Tracker.
    KestrelPoet
  • tysandrtysandr Posts: 90Member ✭✭✭
    edited February 14
    Okay!

    Would you like to insert notices with multicolors, by using a simple "span" structure? Introducing OrangeJuice.nxs, a method that allows you to introduce spans with simple HTML.

    Download here.
    str += '<span class="huh xc-rgba(244,1,1,1)">Representing <span class="xc-green">blood</span>:</span> '
    str += hack + '<span class="xc-rgba(144, 233, 212, 1)">!</span>'
    oj.express(str, 0, -2)



    The main function is oj.express(str, vpos, hpos). Use xc-color to express a color within the class attribute. Place all other custom classes before using xc-color as your last class.

    vpos, defaults to 0
     -2: prints to the top of the block
     -1: prints to the first displayable line (ignores gagged lines)
     0: prints to the triggered line
     1: prints to the next displayable line (ignores gagged lines)
     2: prints to the prompt

    hpos, defaults to 1
     -2: prints to newline at front of positioned line
     -1: prints in front of positioned line (prepending)
     0: prints newline
     1: prints to end of positioned line (append)
     2: prints to end of positioned line & newline

    Really no material difference between hpos,0 & hpos,2 currently. Also, I would avoid using newline (hpos,-2; hpos,2) with prompt positioning (vpos,2) as I seem to have a fixed height for the prompt & it overlaps text once the scrollback moves.

    Hope it works well for you :)
    vote ∘ Explore Nexus mods for Starmourn & Achaeandb for Nexus

    Kestrel
  • RocketCatRocketCat Posts: 89Member ✭✭✭
    tysandr said:
    cool stuff
    Works like a charm! As usual...
    Hi, I'm Ata. Oh and maybe some other people, too. o:) Check out my various packages for Nexus: Vuu combat system, Global Pathfinder, Slicer Tools, Ship compass, JS from command line, and Vitals Tracker.
  • tysandrtysandr Posts: 90Member ✭✭✭
    Just a little update re: NDB, thanks to Squeakum & others, I had a look at the code & it was quite inefficient at highlighting names.

    I rewrote a method that is significantly quicker although it may still not be the optimal method:
    ndb.alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    
    ndb.highlight = function(msg, names, colors) {
      var alphabet = ndb.alphabet
      for (var name in names) {
        var arr   =  names[name]
        var c     = colors[name] || {}
        var color = 'rgba(' + c.r + ',' + c.g + ',' + c.b + ',' + c.a + ')'
        for (var i = 0; i < arr.length; i++) {
          var idx = arr[i]
          // if the next char in the string is not a letter
          if (msg[(idx + 1)] && alphabet.indexOf(msg[(idx + name.length)]) == -1) {
            // replace at the index for the length of the name with the color
            replace_current_line(idx, name.length, name, color)
          }
        }
      }
    }
    
    ndb.sub = function(msg) {
      if (!ndb.options.doHighlight) { return }
      if (typeof client.current_line.parsed_line == 'undefined') { return }
      if (typeof current_text != 'function') { return }
      var coptions = ndb.coptions || {}
      // var now = new Date().getTime()
      var m = {}
      var c = {}
      for (var k in _db) {
        var i = 0
        while (i < msg.length) {
         if (msg.indexOf(k, i) != -1) {
           if (typeof m[k] == 'undefined') { m[k] = [] }
           if (typeof c[k] == 'undefined') { 
             if (_db[k].useColor == true) { 
               c[k] = _db[k].color 
             } else if (coptions[_db[k].faction] != 'undefined') { 
               c[k] = coptions[_db[k].faction]
             } 
           }
           m[k].push(msg.indexOf(k, i))
           i = msg.indexOf(k, i) + 1
         } else { break }
        }
      }
      ndb.highlight(msg,m,c)
      // var n = new Date().getTime()
      // console.log(n - now)
    }
    If you replace the initial ndb.sub within ndb.uiFunctions with this, you should shave about 10-20ms depending on the size of your ndb.
    vote ∘ Explore Nexus mods for Starmourn & Achaeandb for Nexus

  • RocketCatRocketCat Posts: 89Member ✭✭✭
    Quick and easy, similar functionality to Mudlet lua and echo commands.

    JS <javascript> - to execute some javascript
    JSS <javascript> - to JSON.stringify stuff and print it
    ECHO <text> - similar to mudlet, test your triggers


    Hi, I'm Ata. Oh and maybe some other people, too. o:) Check out my various packages for Nexus: Vuu combat system, Global Pathfinder, Slicer Tools, Ship compass, JS from command line, and Vitals Tracker.
    tysandrPoet
Sign In or Register to comment.