Run lua script on node exit
-
- Posts: 97
- Joined: Thu Aug 12, 2021 6:39 pm
Run lua script on node exit
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
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.
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.
-
- Posts: 97
- Joined: Thu Aug 12, 2021 6:39 pm
Re: Run lua script on node exit
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.
-
- Posts: 97
- Joined: Thu Aug 12, 2021 6:39 pm
Re: Run lua script on node exit
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
If you use this solution, set the Sequence field to: Continue()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.
This will simulate an immediate continue button click.
Instead of telling it to wait for the {{end}} duration (which is based on text length), tell it to wait for a bogus message: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?
Code: Select all
required YourCommand()@Message(WaitForever)
-
- Posts: 97
- Joined: Thu Aug 12, 2021 6:39 pm
Re: Run lua script on node exit
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.
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
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.
-
- Posts: 97
- Joined: Thu Aug 12, 2021 6:39 pm
Re: Run lua script on node exit
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?
-
- Posts: 97
- Joined: Thu Aug 12, 2021 6:39 pm
Re: Run lua script on node exit
Wow, works very nicely. Thanks.