Hi !
I made some research on the documentation about the "Items" alternative to "Quests" and I didn't find anything that allow me to fully understand their purpose.
I thought I could use this to check if my player did collect a particular item relative to a quest and just check this condition like :
Items["my_item"].Is_Collected == true
But I guess that it's not been made that way because the only conditions I found is "Is_Item/Name/etc" but not something like Is_Possessed or something approaching.
Can someone help me to understand the purpose of this feature or at least tell me if this kind of info can be found on the documentation or any sample project or even video tutorial I don't know ^^
Thank you in advance
More infos about : Items
Re: More infos about : Items
The Item table just holds data. It doesn't do anything with the data. You can define your own fields such as "Is Collected" or "Weight" or "Cost" and use them however you want. For example, if an NPC gives the player a Banana during a conversation, you could set the dialogue entry's Script field:
is the same as this:
Quests and items share the Item table because the Dialogue System's data structure is based on Chat Mapper. Rather than make up a data structure from scratch, the Dialogue System adopted Chat Mapper's data structure, which had already been refined and proven in many commercial games and other applications for years. However, Chat Mapper doesn't define a data structure for quests. In order to make quest editing accessible in Chat Mapper's interface, quests share the Item table.
When working with items, it's up to you to manage the values in the Item table. You can work with the Item table by putting Lua statements in the Script and Conditions fields of conversations. Or you can set values in your own scripts using the DialogueLua class. For example, if you have a pickup script on your Banana GameObject in the game, you could use this code:
If you're working with items and inventory in your game world, you may instead prefer to use an inventory management asset from the Asset Store, such as S-Inventory or Inventory Pro. The Dialogue System comes with S-Inventory Support and Inventory Pro Support. They provide additional functionality so you don't have to manage the Item table yourself.
- Dialogue Text: "Here, take this banana."
- Script: Item["Banana"].Is_Collected = true
Code: Select all
Item["Escape_Prison"].State = "active"
Code: Select all
Quest["Escape_Prison"].State = "active"
When working with items, it's up to you to manage the values in the Item table. You can work with the Item table by putting Lua statements in the Script and Conditions fields of conversations. Or you can set values in your own scripts using the DialogueLua class. For example, if you have a pickup script on your Banana GameObject in the game, you could use this code:
Code: Select all
DialogueLua.SetItemField("Banana", "Is_Collected", true);
Re: More infos about : Items
Thank you very much for this very detailed answer Tony !
Maybe you could even add it as is in the documentation to get a page describing Items and how to use them? (If there is not)
I didn't see that we could add custom fields on quests and items and it'll be useful. I'll add a Is_Collected field as you said
I've seen in the Quest example that we can add subtasks to a quest. Do you think I can make these subtasks be items to link the items we have to get in the quest with the quest itself?
Thank you again for your answer, the support you provide on DS is priceless!
Maybe you could even add it as is in the documentation to get a page describing Items and how to use them? (If there is not)
I didn't see that we could add custom fields on quests and items and it'll be useful. I'll add a Is_Collected field as you said
I've seen in the Quest example that we can add subtasks to a quest. Do you think I can make these subtasks be items to link the items we have to get in the quest with the quest itself?
Thank you again for your answer, the support you provide on DS is priceless!
Re: More infos about : Items
Hi,
Good idea; I'll add this to the Item section in the manual.
For example, say you have a quest entry to collect 3 bananas. You can define an item named "Banana" with a Number field named "Count". When the player picks up a banana in the game, increment the count:
In your quest entry, you can set the text to include the current count by using the [lua] markup tag:
Gather Bananas
1 / 3 collected
To automatically update the quest tracker HUD after making a change to Dialogue System data, you'll also want to call DialogueManager.SendUpdateTracker(). So your code would change to:
Good idea; I'll add this to the Item section in the manual.
Quest entries (subtasks) can't be items, but their text can reference fields in other items.Shin wrote:I've seen in the Quest example that we can add subtasks to a quest. Do you think I can make these subtasks be items to link the items we have to get in the quest with the quest itself?
For example, say you have a quest entry to collect 3 bananas. You can define an item named "Banana" with a Number field named "Count". When the player picks up a banana in the game, increment the count:
Code: Select all
var currentCount = DialogueLua.GetItemField("Banana", "Count").AsInt;
DialogueLua.SetItemField("Banana", "Count", currentCount + 1);
- Name: "Gather Bananas"
- Description: "Find three bananas."
- Entry 1: "[lua( Item["Banana"].Count )] / 3 collected"
Gather Bananas
1 / 3 collected
To automatically update the quest tracker HUD after making a change to Dialogue System data, you'll also want to call DialogueManager.SendUpdateTracker(). So your code would change to:
Code: Select all
var currentCount = DialogueLua.GetItemField("Banana", "Count").AsInt;
DialogueLua.SetItemField("Banana", "Count", currentCount + 1);
DialogueManager.SendUpdateTracker();
Re: More infos about : Items
Amazing!
Thank you very very much! The "Banana" example fits perfectly my needs.
I'm not yet really familiar with Lua and its interactions with C# but the system seems really flexible so I can't wait to discover every possibilities the Dialogue System gives me
Thank you very very much! The "Banana" example fits perfectly my needs.
I'm not yet really familiar with Lua and its interactions with C# but the system seems really flexible so I can't wait to discover every possibilities the Dialogue System gives me
Re: More infos about : Items
Happy to help!
I can't resist providing one more bit of information. You can expose your own C# methods to Lua (see Register Functions). This is what the S-Inventory and Inventory Pro integrations do. For example, with S-Inventory you can set the Conditions field to this:
I can't resist providing one more bit of information. You can expose your own C# methods to Lua (see Register Functions). This is what the S-Inventory and Inventory Pro integrations do. For example, with S-Inventory you can set the Conditions field to this:
- Conditions: GetItemAmount("Player", "Banana") >= 3
- Dialogue Text: "Here are the 3 bananas I collected."