Hey Tony,
This issue is easier explain through video so I made a quick one:
(after you see the video)
Overall I'd like to call my own function, test if reward is selected, and based on that tell DialogueSystem if it should accept the button click or if it should call my other function that pops up the warning instead. What would be a way for doing that?
Preventing Button From Being Clicked And Calling My Own Code Instead
-
- Posts: 23
- Joined: Sun Nov 29, 2020 8:50 pm
Re: Preventing Button From Being Clicked And Calling My Own Code Instead
Hi,
There are a few ways you can do it. Here are some ideas:
- Add two "No problem" nodes.
- Or make a subclass of StandardUIResponseButton. Override the OnClick() method to check a condition and only call base.OnClick() if the condition is true. You could add a custom field to dialogue entries containing a Lua condition, and evaluate this field in your OnClick() method. You could add another custom field to contain a message to show if it evaluates false.
There are a few ways you can do it. Here are some ideas:
- Add two "No problem" nodes.
- On one, set Conditions to check if the reward is selected. If so, run CollectEventRewards().
- On the other, set Conditions to check if the reward is not selected. If so, say "Select a reward first".
- When the player selects or deselects a reward, call DialogueManager.UpdateResponses().
- Or make a subclass of StandardUIResponseButton. Override the OnClick() method to check a condition and only call base.OnClick() if the condition is true. You could add a custom field to dialogue entries containing a Lua condition, and evaluate this field in your OnClick() method. You could add another custom field to contain a message to show if it evaluates false.
-
- Posts: 23
- Joined: Sun Nov 29, 2020 8:50 pm
Re: Preventing Button From Being Clicked And Calling My Own Code Instead
Thanks, Tony!
I think the StandardUIResponseButton override will do the trick. But I've been struggling with one more thing this whole time that I have to ask about:
I think the StandardUIResponseButton override will do the trick. But I've been struggling with one more thing this whole time that I have to ask about:
Re: Preventing Button From Being Clicked And Calling My Own Code Instead
Hi,
The Dialogue System is in the special folder "Plugins".
Scripts in the Plugins folder compile first. They do not have access to scripts that are outside Plugins.
Scripts that are outside Plugins compile after that. They have access to scripts that are inside Plugins.
Put your subclasses in a folder that it outside of Plugins, such as Assets / MyGame / Scripts.
The Dialogue System is in the special folder "Plugins".
Scripts in the Plugins folder compile first. They do not have access to scripts that are outside Plugins.
Scripts that are outside Plugins compile after that. They have access to scripts that are inside Plugins.
Put your subclasses in a folder that it outside of Plugins, such as Assets / MyGame / Scripts.
-
- Posts: 23
- Joined: Sun Nov 29, 2020 8:50 pm
Re: Preventing Button From Being Clicked And Calling My Own Code Instead
Thanks! This solved it