Skip to content

HTML5 Client Scripting Questions

2»

Comments

  • ThorimThorim California
    edited March 2016
    Right now I'm just trying to figure out how to do the basics on the Client, I'm very used to Mudlet but I can't get anything to work except for the super simple aliases and triggers.

    I'm trying to figure out how to capture my status for things such as prone, deaf or blind. I can't figure out what the command/syntax is to grab things from GMCP, it's not as simple as it was on mudlet for capturing my vitals and stats, and there are few resources from IRE/IRE players doing things FOR the game on the HTML5 client, most resources linked are for learning javascript from websites and other places. I'm not a good coder, and I need things explained to me like I'm 5, along with working things I can dissect.
  • The onGMCP method in a reflex package will fire whenever GMCP data is received.  http://nexus.ironrealms.com/GMCP describes the types of gmcp that you will receive.

    So for example, you can have the GMCP method "Char.Afflictions.Add".  When this comes to your client, it will run the onGMCP function and set the variable args.gmcp_method to "Char.Afflictions.Add"  and args.gmcp_args to a javascript data container with the "name" value set to the affliction that you just received.  If you want to see everything sent, I'd suggest using the chrome developer tools console and using console.log(args) in your script to get an expandable view of the data being sent.  

    I do wish there was more out there on how to use the nexus client, but it really is just getting started.  I'm happy to answer questions, but as I am not a normal player there are things that I do not typically do with the client.
  • ElishaElisha Imperian
    Thorim said:
    One thing I did on mudlet was have an echo next to room names with their vNum. If I had a location-type skill (Farsight/Mind Sense) that gave me a targets room, it would echo the vNum right next to the name. Is this possible on the HTML client?

    Hm. Well, I -think- you could append a variable set to the desired vNum to echo on room change .. but I'd have to look and see.

    Thorim said:
    Another thing I want to do is add to the pre-set windows, is that possible and if so how.

    It -is- possible to both add new windows and modify existing ones, but the ability to add new windows is currently not supported by the devs. Which means that they wouldn't be able to help you with any issues you ran into. I personally haven't done anything on the Nexus client that requires new windows, as that goes a bit deeper into the GMCP than I'm currently comfortable with, but it's certainly something I'd be willing to look into in the future!

    Thorim said:
    And finally, for the time being, when using TAB it targets a mob in the room and sets it as current target. I want to do the same thing with my targetting alias, that way my target's health shows up on the GUI and highlighted like it does when using TAB for targetting.

    This sort of thing would also dip into the GMCP I mentioned before. I think it'd be doable, yeah.
  • When you set a new target using tab targeting, the server will send you target information (via IRE.Target.Set and IRE.Target.Info). You can inform the server that you have set a target (mimicing the behavior of tab targeting) by sending IRE.Target.Set. See http://nexus.ironrealms.com/GMCP#IRE.Target
    Like what we're doing? Why not take a second to vote? Vote for Imperian at http://www.imperian.com/vote
  • RazahkRazahk California
    Eoghan said:
    When you set a new target using tab targeting, the server will send you target information (via IRE.Target.Set and IRE.Target.Info). You can inform the server that you have set a target (mimicing the behavior of tab targeting) by sending IRE.Target.Set. See http://nexus.ironrealms.com/GMCP#IRE.Target
    How would I go about making a targetting alias with that, I've tried a few things and I don't think I'm doing it right.
  • DecDec
    edited March 2016
    Ok, let me see if I can walk you through the basics of GMCP with the nexus client. Let's start with receiving GMCP data. To do so you need to create a function and name it onGMCP.  The name is important and must be exactly "onGMCP".  Now for this example we're going to use the "Char.Vitals" GMCP method to get whether you have balance and equilibrium, and store those in client variables for later use.  Ready? Here's the code for the function:
      
    <pre>if (args.gmcp_method == "Char.Vitals") { set_variable("balance", args.gmcp_args["bal"]); set_variable("equilibrium", args.gmcp_args["eq"]); } </pre>

    What did this do? It set the client variables balance and equilibrium to equal to whether you have balance and equilibrium. You can now reliably use those variables in other code. For example, you could create an alias with the alias text "balance?" and the action "Show a Notice" and text for the notice "Balance: @balance Equilibrium: @equilibrium". Now when you type "balance?" in the client it will show a notice giving you the state of balance and equilibrium.

    Now how about sending GMCP to the server. Let's say you want to use "IRE.Target.Set" to set the target in the client to a specific mob. In this case I'm going to create an alias to target a testing dummy that has the item number "12345". I'm going to call this guy "buford" and make it so when I type "buford" he's targeted. So first I use an alias "buford" with "exact match" as the matching type. Then in the actions I select "execute script". In the script section I put:

    <pre>send_GMCP("IRE.Target.Set", "12345");</pre>

    Now I type in "buford" and . . . nothing seems to happen. Actually something did happen, but only behind the scenes. The game actually did change the target to buford. If I type "kick" and send that without a target, I do in fact kick poor buford (if he is in the room). But the nexus client has the wrong target name in it. This is because to set the target, there's a build in function called "set_current_target". It takes two variables, the target number (as a string) and a value indicating whether or not to tell the game (you want to tell the game. So we change the "execute script" portion to:

    <pre>set_current_target("12345", true);</pre>

    After saving, when we type in "buford" the nexus client updates to show buford (assuming he's in the room--otherwise it'll show none) and "kick" will kick poor buford.

    That, in a nutshell is how to use GMCP. If you have more questions, please feel free to ask
  • RazahkRazahk California
    Dec said:
    Ok, let me see if I can walk you through the basics of GMCP with the nexus client. Let's start with receiving GMCP data. To do so you need to create a function and name it onGMCP.  The name is important and must be exactly "onGMCP".  Now for this example we're going to use the "Char.Vitals" GMCP method to get whether you have balance and equilibrium, and store those in client variables for later use.  Ready? Here's the code for the function:
      
    <pre>if (args.gmcp_method == "Char.Vitals") { set_variable("balance", args.gmcp_args["bal"]); set_variable("equilibrium", args.gmcp_args["eq"]); } </pre>

    What did this do? It set the client variables balance and equilibrium to equal to whether you have balance and equilibrium. You can now reliably use those variables in other code. For example, you could create an alias with the alias text "balance?" and the action "Show a Notice" and text for the notice "Balance: @balance Equilibrium: @equilibrium". Now when you type "balance?" in the client it will show a notice giving you the state of balance and equilibrium.

    Now how about sending GMCP to the server. Let's say you want to use "IRE.Target.Set" to set the target in the client to a specific mob. In this case I'm going to create an alias to target a testing dummy that has the item number "12345". I'm going to call this guy "buford" and make it so when I type "buford" he's targeted. So first I use an alias "buford" with "exact match" as the matching type. Then in the actions I select "execute script". In the script section I put:

    <pre>send_GMCP("IRE.Target.Set", "12345");</pre>

    Now I type in "buford" and . . . nothing seems to happen. Actually something did happen, but only behind the scenes. The game actually did change the target to buford. If I type "kick" and send that without a target, I do in fact kick poor buford (if he is in the room). But the nexus client has the wrong target name in it. This is because to set the target, there's a build in function called "set_current_target". It takes two variables, the target number (as a string) and a value indicating whether or not to tell the game (you want to tell the game. So we change the "execute script" portion to:

    <pre>set_current_target("12345", true);</pre>

    After saving, when we type in "buford" the nexus client updates to show buford (assuming he's in the room--otherwise it'll show none) and "kick" will kick poor buford.

    That, in a nutshell is how to use GMCP. If you have more questions, please feel free to ask
    Thank you very much, those two examples should give me the basis for everything else I need for now. P.S. This sort of thing is what the GMCP help on the wiki should be like, along with many other examples. 
  • RazahkRazahk California
    I'm trying to track my status as prone and set my own variable for it, this script:

    if (args.gmcp_method == "Char.Afflictions.List")
    {
        if (args.gmcp_args["prone"]) then set_variable("prone", 1);
      else set_variable("prone", 0);
    }

    Doesn't work properly, I'm guessing I'm using the wrong language?
  • A couple things:

    1. You need to use javascript formatting.  There is no "then" in javascript, for example.  IFs are in the style of "if (condition) {code} else {else code}" 
    2. Char.Afflictions.List is not going to do what you think it does.  The game doesn't typically send an entire list of afflictions--it sends individual "Char.Afflictions.Add" and "Char.Afflictions.Remove" instead.  The client does keep track of all the afflictions you currently have in the variable GMCP.Afflictions, however, so you don't need to worry about tracking these yourself.
    3. This will throw errors if args.gmcp_args does not contain a "prone" member.  Javascript doesn't work like some other languages in that undefined variables are not the same as false.  
    4. In other situations, such as Char.Vitals, "prone" is always set to either "0" or "1". These are strings.  In javascript "0" counts as true, not false.  You would need to either test the string (== "1") or convert the string to a number with Number().
  • so, I was looking at capturing health and mana from GMCP
    My health is 527 but captured as 5800
    My mana is 550 but captured as 6100 

    Is there some sort of conversion that needs to take place. I used "hp" and "mp" to capture the variables

      set_variable("health", args.gmcp_args["hp"]);
        set_variable("mana", args.gmcp_args["mp"]);
    image
  • Divide by 11.

    "On the battlefield I am a god. I love war. The steel, the smell, the corpses. I wish there were more. On the first day I drove the Northmen back alone at the ford. Alone! On the second I carried the bridge! Me! Yesterday I climbed the Heroes! I love war! I… I wish it wasn’t over."

  • MalyshkaMalyshka your closet
    ily @dec
  • Javascript syntax note:
    Unlike many languages, Javascript has two different equality operators: == (which will coerce/cast the variables to a like type) and === (which will perform no casting). If you know you always want to check a string against a string, you probably want ===, but if you want to compare the string "1" to the number 1, you would want ==.

    For safety, it's become convention to use === almost everywhere, but you can use whichever you feel is appropriate in your code!
    Like what we're doing? Why not take a second to vote? Vote for Imperian at http://www.imperian.com/vote
  • How do I program something to be checked every tick? Would that be under OnGMCP or is there another trigger that can be created for it?

    I ask because GMCP coding is JS and I'm more comfortable with the simplified scripting on Nexus.
    image
  • Ohm said:
    How do I program something to be checked every tick? Would that be under OnGMCP or is there another trigger that can be created for it?

    I ask because GMCP coding is JS and I'm more comfortable with the simplified scripting on Nexus.
    Put your prompt as your trigger, replacing the numbers with wildcards? I'd just use GMCP, though.
    (Ring): Lartus says, "I heard Theophilus once threw a grenade and killed ten people."
    (Ring): Lartus says, "Then it exploded."

    (Ring): Zsetsu says, "Everyone's playing checkers, but Theophilus is playing chess."
  • edited March 2016
    edit-nevermind, wrong thread
  • Is there a way to check if a suffix is null? Trying to do something like:

    alias: kick <suffix>
    IF <suffix> is equal to null kick @tar otherwise
    kick @suffix

    I just can't get it to recognize that my suffix is null. :-/
Sign In or Register to comment.