Running dialog trigger from mod code. (1 Viewer)

colin

Content Creator
Joined
Apr 11, 2016
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.
 

stuntcock

Content Creator
Joined
Jun 5, 2012
Is there any way to manually tell the dialogue controller to run a specific line from mod code?
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();
}
 

colin

Content Creator
Joined
Apr 11, 2016
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:

sby

Content Creator
Coder
Joined
Sep 11, 2012
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
 

colin

Content Creator
Joined
Apr 11, 2016
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:
 

sby

Content Creator
Coder
Joined
Sep 11, 2012
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
 

colin

Content Creator
Joined
Apr 11, 2016
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.
 

Users who are viewing this thread

Top


Are you 18 or older?

This website requires you to be 18 years of age or older. Please verify your age to view the content, or click Exit to leave.