Disable a specific response button
-
- Posts: 8
- Joined: Tue Jan 23, 2024 6:26 am
Disable a specific response button
Hello, I'd like to set a specific response option's button to be disabled, ie interactable = false, if a certain condition is met.
Wondering how to write the LUA to do this.
I want the player to be able to see that they can't choose the option, so I'd be setting a specific "disabled" color in the button component.
Thanks!
Wondering how to write the LUA to do this.
I want the player to be able to see that they can't choose the option, so I'd be setting a specific "disabled" color in the button component.
Thanks!
Re: Disable a specific response button
Hi,
Set that dialogue entry's Conditions. For example:
You can also set the [em#] Tag for Invalid Entries dropdown to show the response button's text in a specific emphasis setting value by automatically adding [em#] markup tags.
If you only want to have "Include Invalid Entries" behavior for certain invalid entries but not others, see this post.
Set that dialogue entry's Conditions. For example:
- Menu Text: "Buy a laser pistol [50 credits]"
- Conditions: Variable["Credits"] >= 50
You can also set the [em#] Tag for Invalid Entries dropdown to show the response button's text in a specific emphasis setting value by automatically adding [em#] markup tags.
If you only want to have "Include Invalid Entries" behavior for certain invalid entries but not others, see this post.
-
- Posts: 8
- Joined: Tue Jan 23, 2024 6:26 am
Re: Disable a specific response button
Thank you so much!
Re: Disable a specific response button
Happy to help!
Re: Disable a specific response button
Hi Tony, I'm following the 2019-05-29.unitypackage post and have 'Include SimStatus' checked, but I'm still getting an error. I noticed that the original post discussed this error later on, but the conversation ended when you were about to test it, with no further updates. For your information, my dialogue has some condition checks when linking to other dialogues... Any hints on how I can solve this?Tony Li wrote: ↑Fri Sep 06, 2024 3:09 pm Hi,
Set that dialogue entry's Conditions. For example:
Then tick the Dialogue Manager GameObject's Display Settings > Input Settings > Include Invalid Entries. This will tell the Dialogue System to include response buttons for entries whose Conditions are false, but it will make them non-interactable.
- Menu Text: "Buy a laser pistol [50 credits]"
- Conditions: Variable["Credits"] >= 50
You can also set the [em#] Tag for Invalid Entries dropdown to show the response button's text in a specific emphasis setting value by automatically adding [em#] markup tags.
If you only want to have "Include Invalid Entries" behavior for certain invalid entries but not others, see this post.
Re: Disable a specific response button
Hi,
Can you back up your project, update to the current DS version, and check again?
If it still reports those errors, let me know.
Can you back up your project, update to the current DS version, and check again?
If it still reports those errors, let me know.
Re: Disable a specific response button
Hi Tony, I've updated DS to version 2.2.48, but the same error still appears. Here are some screenshots from my dialogue settings. Please let me know if I need to provide any additional information to help you find the source of the problem.
This is the parent dialogue entry that links to other entries with conditions:
This is one of the child entries that shows an error:
By the way, I'm awared in the latest version, you solve the bug in if ConversationView from this post. Thank you so much for the hard work!
This is the parent dialogue entry that links to other entries with conditions:
This is one of the child entries that shows an error:
By the way, I'm awared in the latest version, you solve the bug in if ConversationView from this post. Thank you so much for the hard work!
Re: Disable a specific response button
Hi,
Can you send a reproduction project to tony (at) pixelcrushers.com along with reproduction steps?
The error suggests that the wrong conversation has set the Dialog[] Lua variable.
At runtime, each conversation has a Lua table named Conversation[#] where # is the conversation ID. Inside this table is a sub-table named Dialog[#] where this # is the entry ID. So, for example, the SimStatus for conversation 7, dialogue entry 42 is in:
When the Dialogue System's ConversationController gets to a dialogue entry, it sets the alias "Dialog[]" to that dialogue entry's conversation.
If you can't identify why this is happening, you could take a different approach and not use SimStatus at all. Instead, make and use a subclass of StandardUIMenuPanel that overrides the ShowResponses() method. Something like:
Can you send a reproduction project to tony (at) pixelcrushers.com along with reproduction steps?
The error suggests that the wrong conversation has set the Dialog[] Lua variable.
At runtime, each conversation has a Lua table named Conversation[#] where # is the conversation ID. Inside this table is a sub-table named Dialog[#] where this # is the entry ID. So, for example, the SimStatus for conversation 7, dialogue entry 42 is in:
Code: Select all
Conversation[7].Dialog[42].SimStatus
When the Dialogue System's ConversationController gets to a dialogue entry, it sets the alias "Dialog[]" to that dialogue entry's conversation.
If you can't identify why this is happening, you could take a different approach and not use SimStatus at all. Instead, make and use a subclass of StandardUIMenuPanel that overrides the ShowResponses() method. Something like:
Code: Select all
public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout)
{
var list = new List<Response>();
foreach (var response in responses)
{
var showInvalid = Field.LookupBool(response.destinationEntry.fields, "Show Invalid");
if (response.enabled || showInvalid) list.Add(response);
}
responses = list.ToArray();
base.ShowResponses(subtitle, responses, timeout); //edit: fixed method call
}
Re: Disable a specific response button
The overridden method ShowResponses works great! Just a small correction—the last line of the code should be written like this...
Thank you so much for the help!
Code: Select all
base.ShowResponses(subtitle, responses, target);
Thank you so much for the help!
Re: Disable a specific response button
Thanks! I should have a keyboard macro that adds a "may have typos, etc." disclaimer on code examples that I type directly into forum replies. I'll fix that in my post above.