Page 1 of 2

Run lua script on node exit

Posted: Mon Aug 23, 2021 2:47 pm
by hipsterdufus
Hi, is there any way to run a lua script when a conversation node ends as opposed to when it's entered? I notice there some @{{end}} command for sequences. Do I have to use sequences instead?

Re: Run lua script on node exit

Posted: Mon Aug 23, 2021 3:45 pm
by Tony Li
Hi,

Yes, you have to use sequences. The Script field isn't timed; it runs as soon as the dialogue entry is used.

Tip: Use the 'required' keyword if you want to make sure your sequencer command runs even if the player skips ahead before the time that it's supposed to run.

Re: Run lua script on node exit

Posted: Mon Aug 23, 2021 3:50 pm
by hipsterdufus
Thanks. As a workaround, I can add an extra dialogue box that contains nothing but the script. The only problem is I am always using the continue button so it creates an extra click for the player. Is there a way to turn that off temporarily? Maybe that will be good enough for me. If not, I'll have to look into how to use sequences.

Re: Run lua script on node exit

Posted: Mon Aug 23, 2021 4:15 pm
by hipsterdufus
Sorry, I was able to use sequencer and it is functioning but I still have an issue - the @{{end}} seems to trigger as soon as the subtitle text is done displaying. I'd like to trigger the sequence command when the continue button is pressed (or when the dialogue node is exited). Is that possible?

Re: Run lua script on node exit

Posted: Mon Aug 23, 2021 4:30 pm
by Tony Li
hipsterdufus wrote: Mon Aug 23, 2021 3:50 pmAs a workaround, I can add an extra dialogue box that contains nothing but the script. The only problem is I am always using the continue button so it creates an extra click for the player. Is there a way to turn that off temporarily? Maybe that will be good enough for me. If not, I'll have to look into how to use sequences.
If you use this solution, set the Sequence field to: Continue()

This will simulate an immediate continue button click.
hipsterdufus wrote: Mon Aug 23, 2021 4:15 pm Sorry, I was able to use sequencer and it is functioning but I still have an issue - the @{{end}} seems to trigger as soon as the subtitle text is done displaying. I'd like to trigger the sequence command when the continue button is pressed (or when the dialogue node is exited). Is that possible?
Instead of telling it to wait for the {{end}} duration (which is based on text length), tell it to wait for a bogus message:

Code: Select all

required YourCommand()@Message(WaitForever)

Re: Run lua script on node exit

Posted: Mon Aug 23, 2021 6:58 pm
by hipsterdufus
Thanks, I got things working now using a sequence command that waits for a message that the dialog box was closed which comes from my game's code.

It seems like sequences are the same as lua commands but a little more powerful because of the messaging system.

Re: Run lua script on node exit

Posted: Mon Aug 23, 2021 7:58 pm
by Tony Li
They each have their strengths. Sequences are good for timing things; hence the name "sequence." Lua has a more powerful code syntax since it's a full programming language. I generally recommend sequences for things the player experiences -- such as camera shots, animation, etc. -- and Lua for data management -- variables, quest states, etc.

Re: Run lua script on node exit

Posted: Tue Aug 24, 2021 11:41 am
by hipsterdufus
Is there any way to close the Dialogue UI, pause for a few seconds, then reopen the Dialogue UI and continue the conversation on the next node? That would be a good use case for sequences right? I'd like to put some pauses like that in some of the longer cutscene conversations. Otherwise the conversation flows a little too quickly. I could break the conversation up and start the conversation from specific nodes but it would be easier if I can just do it with a sequence. I guess I'd have to write my own sequence to close and open the Dialogue UI?

Re: Run lua script on node exit

Posted: Tue Aug 24, 2021 12:52 pm
by Tony Li
Hi,

Use the SetDialoguePanel() sequencer command.

Re: Run lua script on node exit

Posted: Tue Aug 24, 2021 1:47 pm
by hipsterdufus
Wow, works very nicely. Thanks.