[NEXUS] Rage tracker request

I have been trying for days to figure out how to go about creating a rage tracker, to send it to a variable. Could anyone assist me in this?

I have managed to find the specific bit to probe for, but I can't figure out how to parse it into two separate vars.

What I have is the following:

stats = args.gmcp_args.charstats


As I said above, this returns two bits, both Bleed and Rage. Thank you in advance!
If you write a code, I can send you IG gold.

Comments

  • Something like this?

    bleed = tonumber(gmcp.Char.Vitals.charstats[1]:match("Bleed: (%d+)"))

    modify for Rage as needed.


  • Caelan said:
    Something like this?

    bleed = tonumber(gmcp.Char.Vitals.charstats[1]:match("Bleed: (%d+)"))

    modify for Rage as needed.

    Maybe, but nexus doesn't seem to like that. It keeps requesting more )'s, which I don't see where to put them, as that seems to be enough there. Confusing.
  • Caelan said:
    Something like this?

    bleed = tonumber(gmcp.Char.Vitals.charstats[1]:match("Bleed: (%d+)"))

    modify for Rage as needed.

    Will this work in Nexus?

  • Cooper said:
    Caelan said:
    Something like this?

    bleed = tonumber(gmcp.Char.Vitals.charstats[1]:match("Bleed: (%d+)"))

    modify for Rage as needed.

    Will this work in Nexus?
    No. That code is in Lua, and the Nexus client uses JavaScript. The JavaScript equivalent should be something like this (in addition to the line you already have to set the stats variable):
    rage = parseInt(stats[1].match(/\d+/), 10)
    
    Important things to note:

    Lua is 1-indexed, JavaScript is 0-indexed. So in Lua you use [1] to refer to the first item in a list; in JavaScript, you use 1 to refer to the second item in a list. If you have a list of entries that are Bleed and then Rage, in Lua you'd use 1 to get Bleed and 2 to get Rage, but in JavaScript you'd use 0 for Bleed and 1 for Rage.

    I've assumed the ordering of charstats in the above code. 1 may not be the correct index to use to get the entry for Rage.

    That's about as much help as I can give. I've hardly used the Nexus client, so while I can do general JavaScript I don't know the oddities of how coding for Nexus works (by all accounts variables can be a bit awkward in regards to visibility).
  • Cooper said:
    Caelan said:
    Something like this?

    bleed = tonumber(gmcp.Char.Vitals.charstats[1]:match("Bleed: (%d+)"))

    modify for Rage as needed.

    Will this work in Nexus?
    Missed the Nexus part but even still, assumed it would provide insight enough to get them where they're going.

  • Antonius said:
    Cooper said:
    Caelan said:
    Something like this?

    bleed = tonumber(gmcp.Char.Vitals.charstats[1]:match("Bleed: (%d+)"))

    modify for Rage as needed.

    Will this work in Nexus?
    No. That code is in Lua, and the Nexus client uses JavaScript. The JavaScript equivalent should be something like this (in addition to the line you already have to set the stats variable):
    rage = parseInt(stats[1].match(/\d+/), 10)
    
    Important things to note:

    Lua is 1-indexed, JavaScript is 0-indexed. So in Lua you use [1] to refer to the first item in a list; in JavaScript, you use 1 to refer to the second item in a list. If you have a list of entries that are Bleed and then Rage, in Lua you'd use 1 to get Bleed and 2 to get Rage, but in JavaScript you'd use 0 for Bleed and 1 for Rage.

    I've assumed the ordering of charstats in the above code. 1 may not be the correct index to use to get the entry for Rage.

    That's about as much help as I can give. I've hardly used the Nexus client, so while I can do general JavaScript I don't know the oddities of how coding for Nexus works (by all accounts variables can be a bit awkward in regards to visibility).
    Thank you. This works perfectly. I had changed it to be stats[2] but forgot that multiple bits start at 0. So yes, that is the correct one. Thank you again.
Sign In or Register to comment.