Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | protofan | |
Old Version | Published before Godot 3 was released. |
Currently I am working on a sort of a rpg game that will have dialogue with choices and some options would be avaivable only when certain conditions are met, so I am looking for a good way to handle something like that. I tried to do it with a json file and a dictionary, and couldnt figure out how the whole thing works (cant output inner parts of a key). Besides that if I would use a dictionary, every key should have a few inner keys. I still dont understand how most of json works, but on the previous engine I was working with I was using XML (I still find it easier than json) and my code was looking something like this:
<dialogue>
<line1>
<name>Narrator</name>
<text>Hello there</text>
<condition>talked_already=1</condition>
<tnext>3</tnext>
<fnext>2</fnext>
</line>
<line2>
<name>Narrator</name>
<text>Nice weather, innit?</text>
<result>talked_already=1</result>
<next>exit</next>
</line>
<line3>
<name>Narrator</name>
<text>Whats up?</text>
<next>exit</next>
</line>
**dialogue** is the root node
**line** is the inner node, which says that it is line + line's number
**name** is the text to display in the name box
**text** is text to display in the text box
**condition** is the condition (duh) to take action
**tnext** if condition is true dialogue progress to the selected line
**fnext** if condition is false dialogue progress to the selected line
**result** changes variable or makes other actions depending on the text
**next** used to progress the dialogue
So, when I first tried to pull this off, I found out that godot isnt working with XML that good, and everybody said me to move to json. I moved to json and dont understand how to get the value of individual key (key inside a key).
Other alternative would be using gdscript files as text containers, like this:
extends Node
var line1="Hello there!"
var name1="Narrator"
But I dont know how to make it work, besides that it would look ugly. I tried working with SMRT and GodotTIE, and they either doesnt have tools I need, or dont have tutorials that explain me how to use that tools.
Alternatively I could make my own txt file text parser, but as I get it, I would need to use additional C# code, and I am not the best at it, and as again, Im still dont quite understand how that would work (like, how would I check if there is a condition in that line? Put my values into the string?).
I would continue working in my old engine, but the modability and 3d support of godot keeps me here. So, besides the ways I described above, how else I could store text with variables?
P.S. Oh my god, thats a lot of text D: