Hello!
I'm creating a Battle System with a character, and I would like to have this interact with the Dialogue System.
At the end of the Battle, I have a loot screen.
I would like to have an interaction via script where after earning an "X" loot, the Dialogue System adds an "X" Item to the Database.
How can I make my script and the Dialogue System interact to obtain this behaviour? Thank you so much in advance!
Add Item via script
Re: Add Item via script
Hi,
Do you want to add an item to the dialogue database's Item[] table, or to your own inventory system that's separate from the Dialogue System? I'll assume the latter, since the dialogue database's Item[] table isn't much of an inventory solution.
You'll need a C# method to add an item to your inventory system. Let's say the method is:
Then just register that method with Lua (video tutorial) and use it in a dialogue entry's Script field.
Do you want to add an item to the dialogue database's Item[] table, or to your own inventory system that's separate from the Dialogue System? I'll assume the latter, since the dialogue database's Item[] table isn't much of an inventory solution.
You'll need a C# method to add an item to your inventory system. Let's say the method is:
Code: Select all
public void AddItem(string itemName)
{
// Your code here that adds the item to your inventory system
}
Re: Add Item via script
>Do you want to add an item to the dialogue database's Item[] table
This is my preferred solution, as I want the Battle System to drop something, and I want that something to be inserted in the Item[] table. Then, I'm using the Item as a condition for the resolution of a quest (having a dialogue that checks that you have this item and if yes, the Quest is complete).
Does this make sense? Are there better practices to do this? Thanks
This is my preferred solution, as I want the Battle System to drop something, and I want that something to be inserted in the Item[] table. Then, I'm using the Item as a condition for the resolution of a quest (having a dialogue that checks that you have this item and if yes, the Quest is complete).
Does this make sense? Are there better practices to do this? Thanks
Re: Add Item via script
Hi,
In a dialogue entry's Script field, add the item like this:
In C#, you can use DialogueLua:
In a dialogue entry's Script field, add the item like this:
Code: Select all
Item["Maguffin"] = { Name="Maguffin", Is_Item=true }
Code: Select all
DialogueLua.SetItemField("Maguffin", "Name", "Maguffin");
DialogueLua.SetItemField("Maguffin", "Is Item", true);
Re: Add Item via script
I forgot to thank you in the past for this! It worked and was very useful.
Still, I've got a further question: what if instead of Items I want to manipulate Number variables?
Like this:
I'm in a turn-based battle.
At the end of the battle, the enemy is defeated.
I want the Dialogue System to increase a variable in the dialogues called DefeatedEnemies
I'm able to Set the Variable as of now, but not increasing.
Can I get any help on this? Thanks.
Still, I've got a further question: what if instead of Items I want to manipulate Number variables?
Like this:
I'm in a turn-based battle.
At the end of the battle, the enemy is defeated.
I want the Dialogue System to increase a variable in the dialogues called DefeatedEnemies
I'm able to Set the Variable as of now, but not increasing.
Can I get any help on this? Thanks.
Re: Add Item via script
Hi,
What about:
What about:
Code: Select all
DialogueLua.SetVariable("DefeatedEnemies", 1 + DialogueLua.GetVariable("DefeatedEnemies").asInt);