Modify Affinity using Dialogue System & LUA

Announcements, support questions, and discussion for Love/Hate.
Post Reply
MeneghettiFlux
Posts: 5
Joined: Thu Jul 27, 2017 2:44 pm

Modify Affinity using Dialogue System & LUA

Post 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!
MeneghettiFlux
Posts: 5
Joined: Thu Jul 27, 2017 2:44 pm

Re: Modify Affinity using Dialogue System & LUA

Post 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)));
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Modify Affinity using Dialogue System & LUA

Post by Tony Li »

Ah, you just beat me to it. Sorry about that bug. I'm pushing out an update today to fix it!
MeneghettiFlux
Posts: 5
Joined: Thu Jul 27, 2017 2:44 pm

Re: Modify Affinity using Dialogue System & LUA

Post by MeneghettiFlux »

No problem! Thanks for the quick response and fix! :)
Post Reply