Dialogue system Quest Reward direct to Invector inventory ?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Rai Jo
Posts: 2
Joined: Sun Aug 19, 2018 5:25 am

Dialogue system Quest Reward direct to Invector inventory ?

Post by Rai Jo »

Compatible to give a reward of Dialogue system Quest direct Invector inventory ?
User avatar
Tony Li
Posts: 22057
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue system Quest Reward direct to Invector inventory ?

Post by Tony Li »

Hi,

There is no built-in way to give an Invector inventory item. Not all of the Invector controllers have an inventory system, so it's not included in the Dialogue System integration. To add a reward, you must write a little code. Here are some different ways to do it:

1. Use the SendMessage() sequencer command. Add a script to the player that has a method named GiveInvectorItem:

Code: Select all

public string GiveInvectorItem(string itemName)
{
    // Your code here to add Invector item to inventory.
 }
In a dialogue entry node, use it like this:
  • Speaker (actor): NPC quest giver
  • Listener (conversant): Player
  • Dialogue Text: "Here is a Fire Sword."
  • Sequence: {{default}}; SendMessage(GiveInvectorItem, Fire Sword, listener)

2. Or you can register a C# method with Lua:

Code: Select all

void OnEnable()
{
    Lua.RegisterFunction("GiveInvectorItemToPlayer", this, SymbolExtensions.GetMethodInfo(() => GiveInvectorItemToPlayer(string.Empty)));
}

public void GiveInvectorItemToPlayer(string itemName)
{
    var player = GameObject.FindObjectWithTag("Player");
    // Your code here to add itemName to player.
}
Use it in a dialogue entry node like this:
  • Speaker (actor): NPC quest giver
  • Dialogue Text: "Here is a Fire Sword."
  • Script: GiveInvectorItemToPlayer("Fire Sword")
Post Reply