Page 1 of 1

How to add nodes in runtime?

Posted: Tue Oct 24, 2023 3:41 pm
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.

Re: How to add nodes in runtime?

Posted: Tue Oct 24, 2023 4:15 pm
by Tony Li