How to write "Found"/"Not Found" in quest description from a variable

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Strook
Posts: 70
Joined: Fri Nov 08, 2019 10:51 am

How to write "Found"/"Not Found" in quest description from a variable

Post by Strook »

Hello! This should be pretty straightforward, but I feel like Im missing something:

- I have some boolean variables related to the state of some objects in game
- I have a quest showing the state of those objects, and I'd like to display it like this :

-Object A: Found
-Object B: Not Found
-Object C: Found
Right now I have (as a placeholder) simply written it like this in my Quest Entry Description field:

Code: Select all

-Object A: [var=QuestObjects.ObjectA]
Where Object A is my boolean. Of course this displays "- Object A: true" which is not what I want!


What would be the easiest way to achieve something like this?

Thanks :)
Currently working on ->Squeakross: Home Squeak Home<- Using Dialogue System Save System and other features.
Previous game made with Dialogue system ->The Spirit and The mouse<-
User avatar
Tony Li
Posts: 22152
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to write "Found"/"Not Found" in quest description from a variable

Post by Tony Li »

Hi,

You'll need to use a Lua expression. In case you want to dig into the details of how it works, see Ternary Operator. If you just want to get it working, change this:

- Object A: [var=QuestObjects.ObjectA]

to this:

- Object A: [lua( Variable["QuestObjects.ObjectA"] and "Found" or "Not Found" )]
User avatar
Strook
Posts: 70
Joined: Fri Nov 08, 2019 10:51 am

Re: How to write "Found"/"Not Found" in quest description from a variable

Post by Strook »

Awesome, Thanks a lot Tony
Currently working on ->Squeakross: Home Squeak Home<- Using Dialogue System Save System and other features.
Previous game made with Dialogue system ->The Spirit and The mouse<-
User avatar
Tony Li
Posts: 22152
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to write "Found"/"Not Found" in quest description from a variable

Post by Tony Li »

Happy to help!
User avatar
Strook
Posts: 70
Joined: Fri Nov 08, 2019 10:51 am

Re: How to write "Found"/"Not Found" in quest description from a variable

Post by Strook »

i was just wondering, how would you go about localizing this? Is it possible to grab the keyword from a text table? Thanks!
Currently working on ->Squeakross: Home Squeak Home<- Using Dialogue System Save System and other features.
Previous game made with Dialogue system ->The Spirit and The mouse<-
User avatar
Tony Li
Posts: 22152
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to write "Found"/"Not Found" in quest description from a variable

Post by Tony Li »

You could put the localization straight into the localization fields:
  • Dialogue Text: Object A: [lua( Variable["QuestObjects.ObjectA"] and "Found" or "Not Found" )]
  • es: Object A: [lua( Variable["QuestObjects.ObjectA"] and "Detectado" or "No detectado" )]
  • fr: Object A: [lua( Variable["QuestObjects.ObjectA"] and "Détecté" or "Non-détecté" )]
  • ja: Object A: [lua( Variable["QuestObjects.ObjectA"] and "位置した" or "見つかりません" )]

Or you could register DialogueManager.GetLocalizedText() with Lua. Call it something like GetTranslation() because GetLocalizedText() is already a Lua function that gets the localized version of database content.

Code: Select all

Lua.RegisterFunction("GetTranslation", null, SymbolExtensions.GetMethodInfo(() => DialogueManager.GetLocalizedText(string.Empty)));
Then use that C# method:
  • Object A: [lua( Variable["QuestObjects.ObjectA"] and GetTranslation("Found") or GetTranslation("Not Found") )]
Post Reply