globalDict is not Python. It is an attribute of module bge.logic. It is a dictionary that is created on starting the game. It is supposed to be used to feed the save/load-actuators. It is not supposed to serve as anything else even when some people recommend that. There is really no problem to create your own dictionary, or other container to keep data that is not supposed to serve the save/load-actuators.
Your current situation is a typical example that globalDict is no good choice. Using it for dialog options denies the option to use load/save-actuators as it conflicts with them. More important, a dictionary is most-likely not the best object to manage your dialogs.
I suggest you design a separate dialog option object. You could call it dialog provider.
Think about what it should do and what it should not do (because other objects can do it better).
Here are some thoughts:
- keep the status of a dialog (current node)
- provide options for the current node
- transit to a connected node (switching the current node)
Your dialog nodes can be a tree, but most-likely you want a graph (a tree has no loops).
A dialog has a start node, and several final leaves (where there are no further options). Usually the graph should always end in a leaf (no endless cycle).
A graph is easy to draw with pen and paper. But this is not really sufficient when you add the textual information. Electronically graphical representations are not really sufficient especially on larger graphs.
I suggest to use tables. It is harder to see the connections but easier to edit and maintain.
You need at least two tables:
nodes and edges
Nodes describe a single text statement
Edges describe the transition between test statements. You will need directed edges.
So a node can be a question. The connected nodes are the possible answers. Each of them leads to other questions/statements.
I suggest to fill Nodes with keys rather than with full fledged texts. This keeps the graph abstract and allows to use textmapping to several different languages. If aiming for single language systems you will still benefit from key to text mapping as it support the authors much better than a confusing graph.
What structure to use?
Nodes can be defined in a table (of keys). Edges can be defined in a dictionary with node keys as key and node keys as next state:
nodes = [
"greetings",
"welcome"
"ask.for.shop",
"ask.for.shop.type",
"ask.for.shop.bakery",
"ask.for.shop.food",
...
]
edges = {
"greetings": "welcome",
"welcome": "ask.for.shop",
"ask.for.shop": "ask.for.shop.type",
"ask.for.shop.type": "ask.for.shop.bakery",
"ask.for.shop.type": "ask.for.shop.food",
...
}
In this simple example you could skip the nodes list. In a more complex design, you would feed each single node with more details.
This graph is pretty simple. It starts with single alternatives. The ask.for.shop.type node results in tow options that the player or the NPC needs to chose from.
Now you need a text mapping (which should be kept separate from dialog design):
greetings = Hello
welcome = Hello
ask.for.shop = Where can I find a shop in this city?
ask.for.shop.type = What kind of shop you are thinking of?
ask.for.shop.bakery = A bakery.
ask.for.shop.food = A food shop
...
with that structure you can easily create translated text:
greetings = Moin
welcome = Guten Tag
ask.for.shop = Wo finde ich in dieser Stadt einen Laden?
ask.for.shop.type = An welcher Art Laden, denken Sie?
ask.for.shop.bakery = Eine Bäckerei.
ask.for.shop.food = Wo es was zu Futtern gibt.
...
I hope you get the idea.