1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Running dialog trigger from mod code.

Discussion in 'Help' started by colin, Jul 6, 2016.

  1. colin

    colin Avid Affiliate Content Creator

    Joined:
    Apr 11, 2016
    Messages:
    59
    Likes Received:
    22
    Is there any way to manually tell the dialogue controller to run a specific line from mod code? I am thinking something along the lines of:

    Dialogue piece:
    help1:"I need help to get this working"
    help2:"Because there are too many different dialogue components"
    helpnotfound:"Apparently I did this wrong"

    Mod pseudocode snippet:
    if (setValue == "ineedhelp")
    runTrigger("help1");
    else if (setValue == "toomanyoptions")
    runTrigger("help2");
    else
    runTrigger("helpnotfound");

    The idea is that my auto movement function mod will let dialogues specify a condition, and a line to jump to when that condition is met, this way someone could tell the mod to have her keep going deeper, then when it hits a certain point it could trigger a specific line from the dialogue.
    So using my mod they could say start moving between main.g.currentPos().x == -0.2 and 0.2, increasing the maximum by 0.1 every 20 frames until main.g.currentPos().x == 0.8, then run the line labeled tooDeep.
     
  2. stuntcock

    stuntcock Club Regular Staff Member Moderator

    Joined:
    Jun 5, 2012
    Messages:
    1,520
    Likes Received:
    352
    Ideally, we'd make calls directly to the dialogueActions mod (e.g. the TriggerManager class). Unfortunately, it doesn't seem to register itself for inter-mod communication. You might be able to achieve something by calling the vanilla SDT methods instead:

    Code:
    public function initl(l)
    {
       var Dialogue = l.eDOM.getDefinition("obj.dialogue.Dialogue") as Class;
       var DialogueLine = l.eDOM.getDefinition("obj.dialogue.DialogueLine") as Class;
      
       // If you just want her to speak something arbitrary
       l.g.dialogueControl.startSpeakingPhrase(new DialogueLine("foo! bar?", null));
      
       // If you want her to speak one of the vanilla line-types
       l.g.dialogueControl.maxState(Dialogue.FIRST_DT);
      
       // If you want her to speak a custom line-type
       l.g.dialogueControl.maxState("FooBar");
       // Note: does nothing unless you've already loaded a custom dialogue in which "FooBar" is defined
      
       l.unloadMod();
    }
    
     
  3. colin

    colin Avid Affiliate Content Creator

    Joined:
    Apr 11, 2016
    Messages:
    59
    Likes Received:
    22
    Thank you for the fast response, I was looking for something like that last call, but unfortunately it does not appear to work. Even when I use a hard coded line for testing it still appears to have no effect. I am trying to call

    ft2:"I'm not sure how much wider he can spread my throat."{"style":"thought"}

    using code:
    main = l;
    main.g.dialogueControl.maxState("ft2");
    main.updateStatus("dialogueControl used");

    The result is no dialogue is triggered, but "dialogueControl used" is displayed.

    Oh and I looked at trigger manager (it actually has a runTrigger function that can be used from other functions) but the trigger you want to use must first to be registered with registerTrigger. It only appears to be for function triggers, not line triggers unless I missed something running through it (definitely a possibility.)

    Edit: Ok, I finally managed to parse through it, and the maxState function attempts to read from a state in dialogue control, however it does not add custom lines to the states. I have not yet found the location where it processes line triggers.

    l.g.dialogueControl.triggerState("line_name");
    ALMOST works, but for some reason it cuts off the first unit in the line. For the dialogue line I used above, it displays: " not sure how much wider he can spread my throat."
    and yes, it does leave the space before "not". If you replace "I'm" with [GAG] it will result in the same display, and no GAG will occur.
     
    Last edited: Jul 6, 2016
  4. sby

    sby Club Regular Content Creator

    Joined:
    Sep 11, 2012
    Messages:
    1,331
    Likes Received:
    73
    i may have done what you are talking about in animtools. i called it shady DA injection. seems like most of this already mentioned though

    used it to trigger dialog actions masturbate feature

    Code:
    if(enableshadyDAinjection == 1)
      {
      if(DAhermasterbate == 1)
      {
      if(!g.dialogueControl.words)
      {
      g.dialogueControl.words = new Array();
      }
    
      if(g.dialogueControl.waitingToContinue || g.dialogueControl.speaking) //currently in dialog
      {
      //if(loadermode)main.updateStatus("insert");
      g.dialogueControl.words.push(new Word("[MASTURBATE_ON]"));
      }
      else
      {
      //if(loadermode)main.updateStatus("new line");
      g.dialogueControl.startSpeakingPhrase (new DialogueLine("[MASTURBATE_ON]",null));
      g.dialogueControl.instantStop();
      g.dialogueControl.speaking = true;
      }
    
      }
      else
      {
      if(!g.dialogueControl.words)
      {
      g.dialogueControl.words = new Array();
      }
    
      if(g.dialogueControl.waitingToContinue || g.dialogueControl.speaking) //currently in dialog
      {
      //if(loadermode)main.updateStatus("insert off");
      g.dialogueControl.words.push(new Word("[MASTURBATE_OFF]"));
      }
      else
      {
      //if(loadermode)main.updateStatus("new line off");
      g.dialogueControl.startSpeakingPhrase (new DialogueLine("[MASTURBATE_OFF]",null));
      g.dialogueControl.instantStop();
      g.dialogueControl.speaking = true;
      }
      }
      }
    
    also
    g = l.g;
    DialogueLine = l.eDOM.getDefinition("obj.dialogue.DialogueLine") as Class;
    same thing with word class
     
  5. colin

    colin Avid Affiliate Content Creator

    Joined:
    Apr 11, 2016
    Messages:
    59
    Likes Received:
    22
    PERFECT! That works exactly as I had hoped. I think this will let me put the finishing touches on my mod, allowing reasonably intricate scripting for dialogues.

    Thank you both for your help:smile:
     
  6. aztlan

    aztlan Swell Supporter

    Joined:
    Sep 14, 2013
    Messages:
    507
    Likes Received:
    15
    Hmmm... Looking forward to seeing what you come up with...
     
  7. sby

    sby Club Regular Content Creator

    Joined:
    Sep 11, 2012
    Messages:
    1,331
    Likes Received:
    73
    also, called it shady DA injection because i haven't done much with dialog actions, so not very sure how consistent it will work. just seemed shady to inject dialog lines into the queue or into the current phrase xD
     
  8. colin

    colin Avid Affiliate Content Creator

    Joined:
    Apr 11, 2016
    Messages:
    59
    Likes Received:
    22
    Understood. I actually set it up to interrupt any current dialogue as anyone messing around with the function I created should have a very good idea of where they should be in the dialogue. This results in cutting it off mid-line if that is when it is called, because if they set up those conditions it is unlikely that they would want it to wait.