Using Conditional Statments in Labels Within Single Lines/Paragraphs

Godot Version

4.2.1

Question

I started my game in Twine, found it did not have all of the capabilities I needed to make my game, and have since been working on rewriting everything I’ve done so far in Godot. One major facet of my game is specific variables (generally relating to character customization) heavily altering the body text of scenes, such as by adding single sentences to paragraphs, or by extending sentences within paragraphs. In some cases this is accomplished by simply naming variables, but in many cases I accomplished this with if statements.
My format in Twine would look similar to this:
You have $eyecolor eyes<if $eye is "crazyeye">, which frantically flit about, seeming to refract in the light.<else>.</if>
(of course, with many more statements wrapped in it, but this is simplified.)
Is there a way to do something functionally similar to this using Godot’s labels?

No, it’s not possible. You’ll need to find out if there’s a twine plugin for godot or if there’s any way to port the twine text to godot. If there’s nothing then you’ll need to write your own parser and parse it yourself.

If you don’t mind rewriting the text to other systems then you can try using the multiple addons to write dialogues that exist for godot like GitHub - nathanhoad/godot_dialogue_manager: A powerful nonlinear dialogue system for Godot or GitHub - dialogic-godot/dialogic: 💬 Create Dialogs, Visual Novels, RPGs, and manage Characters with Godot to create your Game!

1 Like

Thank you for the answer. There’s a way I can still produce text like this despite the limitation of every conditional statement making a new line, but it will be a lot more annoying to do and require a lot more work and duplication than if I could simply wrap conditional statements within lines.
I need Godot because although I’m making what is primarily a text-based RPG, there are many elements to the game that text-based game engines are not capable of handling. The most ideal thing I could think of would be there being a plugin for Godot that adds this capability, but I suppose it isn’t in high demand.

The Dialogue Manager has inline conditions godot_dialogue_manager/docs/Writing_Dialogue.md at main · nathanhoad/godot_dialogue_manager · GitHub

I’ve not tested it but your example would look like:

Character: You have {{eyecolor}} eyes[if eye == "crazyeye"], which frantically flit about, seeming to refract in the light.[else].[/if]

Thank you! This solves my problem.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.