How to add nodes in runtime?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Znoleg
Posts: 2
Joined: Tue Oct 24, 2023 1:28 pm

How to add nodes in runtime?

Post by Znoleg »

Hi! That's the first day when I started to use this awesome plugin. Our team already has some code and systems set-up in our project, and I'm trying to get them well along. I think I need something as adding nodes in real-time.

Consider the following:
1. I have some data inside a component of game entity. To be precise that's a collection of items that NPC sell that consist of: Type of the item to sell, Name of the item to sell, Current quantity of the item. Inside another system we have a price of the item.
2. Players should have the option to buy items of NPC through conversational interactions. Note that I don't know how many replies I have to create if only using conversation system editor (it can be 3, 4, 5, any number of items I don't know in advance).

Possible replies should look like this:
1) Seed - Tomato - 20 gold
2) Seed - Potato - 30 gold
3) Equipment - Watering Can - 50 gold

As I cannot anticipate the quantity of items that the NPC can sell, I believe I require a method for adding nodes, rather than manipulating variables.

I have tried to create a custom Lua function that is called when conversation reaches "Selling" non-text node, but I didn't find an API to add nodes to existing conversation. The only thing I found is manipulating database data, but it looks complicated, because I need not only to add the dialogue entry, but also configure nodeConnections.

Any suggestions on how to implement this behavior? Thanks.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add nodes in runtime?

Post by Tony Li »

Post Reply