Preventing Button From Being Clicked And Calling My Own Code Instead
Posted: Wed Dec 16, 2020 8:45 pm
by EntertainmentForge
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?
Re: Preventing Button From Being Clicked And Calling My Own Code Instead
Posted: Wed Dec 16, 2020 9:37 pm
by Tony Li
Hi,
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".
- Or tick the Dialogue Manager's Input Settings > Include Invalid Response checkbox, and optionally set [em#] Tag For Invalid Responses. This will show the button in a disabled (non-clickable) state. You can use the Hover example on the Extras page to show a message when the player hovers on the disabled button. This post contains information that explains how to only show specific invalid responses.
- 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.
Re: Preventing Button From Being Clicked And Calling My Own Code Instead
Posted: Fri Dec 18, 2020 2:02 am
by EntertainmentForge
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:
Re: Preventing Button From Being Clicked And Calling My Own Code Instead
Posted: Fri Dec 18, 2020 9:52 am
by Tony Li
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.
Re: Preventing Button From Being Clicked And Calling My Own Code Instead
Posted: Fri Dec 18, 2020 2:52 pm
by EntertainmentForge
Thanks! This solved it
Re: Preventing Button From Being Clicked And Calling My Own Code Instead