Page 1 of 1

Dynamic Conversations without too many variables?

Posted: Mon Jun 17, 2024 6:36 am
by 2linescrossed
Hi, thank you for bearing with this question of mine:

To explain - I want a subtitled conversation (not a bark) that explains the current situation of a card game, like which player won a hand or not.
Problem is that while I have the actors' names/which characters are present in the game, I'm not super sure how to pass 'winning' players to the conversation to have fields in the text update? I imagine I could use conditionals to also check how many players won if at all, to condense all the possible outcomes in the conversation itself.

I know I can register C# Methods to help with this but there's a lot of moving parts so I'm unsure what the best route forward is.

To summarize:
- I want dialog to update based on winner amount + who the winners are.
- This means I'll have to read the game's values (I have arrays with the right player objects in them), but it's feeding the right strings and quantities to the LUA-side of the conversation that confuse me, since I don't understand when I'd get the timing for it or when it happens.

Oh, and if I want the game to wait until the conversation's done, do I just use a while loop checking for whether the conversation's ended or not? (And apologies for the simpler question, but what's the method that checks whether there's any ongoing conversations or not? I assume that would return a bool which I could feed into this loop.)

Re: Dynamic Conversations without too many variables?

Posted: Mon Jun 17, 2024 8:25 am
by Tony Li
Hi,

Write your conversation using a generic Player actor. If necessary, at runtime you can tell the Dialogue System to use a specific actor in place of the generic one. For more info on this, see: Character GameObject Assignments.

If you only need to show the winner's name and amount, you can set two Lua variables before the conversation starts. Example C# code:

Code: Select all

DialogueLua.SetVariable("Winner", winnerName);
DialogueLua.SetVariable("WinningAmount", winningAmount);
DialogueManager.StartConversation("Won Hand");
In your conversation:
  • Dialogue Text: "[var=Winner] won $[var=WinningAmount]."
If your needs are more complex, then represent each player by a GameObject (even an empty GameObject). Pass that GameObject as the conversation's actor:

Code: Select all

DialogueManager.StartConversation("Won Hand", wildBill.transform);
This will set several values:
  • C# property DialogueManager.currentActor will be set to the GameObject's transform.
  • Lua variable Variable["Actor"] will be set to the actor's display name.
  • Lua variable Variable["ActorIndex"] will be set to the actor's index in the Actor[] table.
Sequencer commands such as Camera(Closeup, speaker) will do a closeup of the player GameObject when the player is assigned to the dialogue entry.

You can also register your own C# methods with Lua, such as:

Code: Select all

public double GetWinningAmount() 
{
    // return winning amount for DialogueManager.currentActor.
}
Then use that in your dialogue text:
  • Dialogue Text: "[var=Winner] won $[lua(GetWinningAmount())]."