Nexus - GMCP - Advanced Scripting

Please do not provide answers involved the Simplified_Scripting system. All questions are looking for solutions that will go into the onGMCP function, so please, pretty-please-with-a-cherry-on-top, do not provide answers involved the Simplified_Scripting system.

  1. Capture text in advanced scripting (trigger without touching the simplified scripting system).
  2. Write a Wait For trigger in advanced scripting system (inside a function inside of the onGMCP reflex).
  3. Conditional triggers. If (captured text && variableTrue) {do this};
  4. Connect multiple triggers. If A then B, do E, but not if B happens without A or if A occurs after B. Also, if C then D, do E, but not if D happens without C or if C occurs after D.


Answers

  • You are asking way too much of the human brain.
    Your questions:
    1. Too vague.  If you just write a regex trigger to capture Trigger text:: (.+) as the trigger, then a script that says let capturedText = args[1]; in the script window.
        But that will capture anything and trigger on everything that pops into your GUI window.
    2. Wait scripting doesn't work in the GUI scripting window.  Why?  I don't know.  The Nexus GUI window isn't the HTML document and it isn't a JavaScript source code document.  There is code that accepts the code you put into the settings > reflexes of the nexus client that takes your input and somehow runs it as if it were part of the source code.  For the most part, you can put JavaScript code in as thought you were writing the source code for the webpage that is the Nexus GUI, but it isn't.  Talk to the creators of Nexus if you wan't it to be able to "wait." 
       Side note: be carefull what you put into onGmcp and onLoad.  You could wind up with infinite loops that you wouldn't think are infinite with onGmcp and you could break your GUI with onLoad (I've done both).
    3.    Not sure what you mean:  "If (captured text")  is unnecessary since triggers don't trigger if there is no text, and if your trigger is regex trigger it automatically captures at the very least the whole triggering string (args[0]) and for each set of parenthesis in the regex Trigger text add one to the index ( args[1], args[2], args[3], etc).
       and "If variableTrue" is as simple as "If (variable) { code }."
    4.  To "connect multiple triggers" what you do is not what you think.  The output of one trigger is going to be a unique command (this is how I do it) because you can't trigger a trigger with a trigger.  Triggers only react to what achaea sends back, not what you send.  So:
        trigger A has the script "send_command("B1234");"
        trigger B has the Trigger text: "B1234"

      If you want A to trigger, followed by B in order to activate E, Have the trigger of A set a variable aTrue to true or 1.  Have B trigger say If (aTrue) {"send_command("E1234");"}  and have E trigger Trigger text: "E1234" and script window:
    {do whatever} and { aTrue = false; or aTrue = 0}

    Also












  • nevermind the "also"  but as you can see probably when trying to understand my reply, it's hare to understand what someone is saying when no actual script is included.
  • As I look back at your question, You wanted "solutions that will go into the onGMCP function"

    1. Capture text in advanced scripting (trigger without touching the simplified scripting system).
        Answer: You cannot capture text within the onGMCP function.  Any triggers youc reate here will be separate reflexes and appear below the . onLoad function and the onGMCP function.

    2. Write a Wait For trigger in advanced scripting system (inside a function inside of the onGMCP reflex).
        Answer:  A "Wait For" trigger inside the onGMCP function/reflex would be useless as there would never be anything returned to the function.  GMCP would happen, your function would wait for who-knows-what, who-knows-what would never return to the function.

    3. Conditional triggers. If (captured text && variableTrue) {do this};
         Answer: Not Applicable since there will be no text available for the onGMCP function to capture in the first place.

    4. Connect multiple triggers. If A then B, do E, but not if B happens without A or if A occurs after B. Also, if C then D, do E, but not if D happens without C or if C occurs after D.
        Answer:  As I said in answer one, you cannot put triggers inside the onGMCP function.

    Note: Aliases activate based on what you type in and enter in the command field of your GUI.
              Triggers activate based on what appears in your text window above the command field of your GUI.
              onGMCP triggers when information is sent from the server to your client.  It doesn't appear in the window.
    Let me know if you read this, and if you understand it.
    Shreg












  • onGMCP is fired when the server sends specific events. They're all listed in the documentation, and you can click "Echo all GMCP events" on the Advanced tab of the scripting system to see what's coming in. While the GMCP events are super useful, they don't cover everything that happens to your character.

    Based on your questions, you might want to look at the onBlock function. That function is called every time a prompt is printed. Prompts are hidden by default in the Nexus client, but if you want to get an idea how often onBlock gets called, you can turn prompts on by unchecking both "do not show prompts" and "only show the last status/prompt line received" and you will see every time a prompt comes up. onBlock is given all the text that was sent to the client before the most recent prompt. You can inspect what has been sent in and make many of the types of decisions that you're asking about using this information.

    Between onGMCP and onBlock you can capture all the information the server sends to the client. You will get it in pieces, however, and you cannot "wait" so your code will have to use a more asynchronous paradigm.
  • @Rinnai Do you know how to use promises or async await to send commands asynchronously?

    I’d like to send a command IF a gmcp arg equaled a string and wait for a particular trigger text before sending a second command.

    I can’t seem to get .then resolve reject to render correctly.
  • Let me see if I understand what you're trying to do.

    onGMCP: inspect message and arguments, and if it's interesting ...

    onTrigger: take an action, but only if a recent onGMCP was interesting.

    If so, all you need to do is set a flag in onGMCP, and inspect then clear it in the trigger.
  • I set a flag in GMCP to enable and disable the trigger, but it's not firing.

    Is this the correct syntax? 

    reflex_find_by_name('trigger’, ‘styna_trigger’);
    reflex_enable(‘styna_trigger’);
    reflex_disable(‘styna_trigger’);

    note: I mean to use straight quotes where the curly ‘ is in the code above, but my keyboard won’t let me type it out in this example.

    Question: is the syntax above correct? Is the reason why styna_trigger isn’t working is that it’s enabled too late? Would enabling it beforehand capture the text?
  • @Shreg @Rinnai Hopefully, this explaination below is a littler clearer on what I’m attempting.

    I started with a block statement in onGMCP. It says IF gmcp method matches a string (check IF gmcp argument matches a string) then send command #1.


    Command #1 causes the client to receive gmcp data. I use an IF statement and loop through the gmcp arguments to see if it matches a string. If the string is -1/undefined/missing, then send command #2.


    Wait For a particular line of text to return from command #2. If the line is not returned, exit out. If the line is returned, send command #3. 

  • How about this:

    in onLoad:
    >let stepCount =0;

    in your onGMCP block:
    >if ( gmcp argument matches a string && stepCount = 0 )
    >      stepCount=1;
    >      send Command 1;

    in a second onGMCP block:
    >      loop through the gmcp arguments
    >      If ( the string is -1/undefined/missing ) {
    >            stepCount=3;
    >            send command #2;
    >            }
    >      else stepCount =0;

    in a third onGMCP block:
    >      loop through the gmcp arguments
    >      if ( the srting is found ) send command #3
    >      else stepCount =0;
         

    Here I don't see any need for a wait type code block.  If you want to let several gmcp messages return from the server while checking for command #2's response, then set up the last block like this:


    in a third onGMCP block:
    >      loop through the gmcp arguments
    >      if ( the srting is found ) send command #3
    >      else stepCount += 1;
    >      if stepCount == (however many times you want to check) stepCount= 0;


    If you literally want to wait a certain amount of seconds while checking the response from command #2 then you WILL HAVE TO USE SIMPLIFIED SCRIPTING.  See my answer to your "Wait for Trigger Without Using Simplified System" post.




















Sign In or Register to comment.