Page 1 of 1

Modify Affinity using Dialogue System & LUA

Posted: Thu Jul 27, 2017 3:02 pm
by MeneghettiFlux
Hello!

I'm implementing a very simple Affinity System using Love/Hate and Dialogue System on a prototype, where I have an NPC (with it's own faction) and the conversation branches where some options will modify the affinity with the player (just for testing, so it's a really simple Dialogue Tree) and modify which branch of dialogue will appear to the player.

I'm using LUA Scripting at certain dialogues that will modify the Affinity, but It appears as they are only Setting, not Modifying the value. For example, I have a dialogue where the NPC will decrease the Affinity for the player by 1, and another that will increase by 1. But even if I always choose one or the other, the affinity never goes different than 1 or -1. It doesn't even go to Zero! I'm probably missing something here. Can anyone help?

Below are scripts being used at the Player Dialogues:

Scripts:
ModifyAffinity("RedInmate", "Player", -1)
ModifyAffinity("RedInmate", "Player", 1)

Image

Image

Thanks!

Re: Modify Affinity using Dialogue System & LUA

Posted: Thu Jul 27, 2017 4:08 pm
by MeneghettiFlux
I found the problem... Inside the "LoveHateLua.cs" that come with the Third Party Support for Dialogue System, the registration of the function "ModifyAffinity" is using the wrong function, as seen in the image below:

Image

I just needed to modify that line (38) to:

Code: Select all

Lua.RegisterFunction("ModifyAffinity", null, SymbolExtensions.GetMethodInfo(() => ModifyAffinity(string.Empty, string.Empty, (double) 0)));

Re: Modify Affinity using Dialogue System & LUA

Posted: Thu Jul 27, 2017 4:22 pm
by Tony Li
Ah, you just beat me to it. Sorry about that bug. I'm pushing out an update today to fix it!

Re: Modify Affinity using Dialogue System & LUA

Posted: Fri Jul 28, 2017 9:47 am
by MeneghettiFlux
No problem! Thanks for the quick response and fix! :)