The Cycle - Devlog 08
My goal for today was to figure out the dialogue system, allowing various scripts to initialise the dialogue box and populate it with content. This would also need a way to then allow the user to interact and the scripts to capture the input.
But first, I wanted to figure out how I would handle the different "states" of the level. I identified 4 main states to start with.
TribeCamp. Each of these states will have custom code to handle the specific logic needed. For example,
Wondering would only take care of moving the player along the path and transition to the other states, where
TribeCamp will implement all the logic for the different puzzles. Which, it can also handle through a state machine.
To achieve this, I implemented a state machine to separate the logic of each state into its own script and allow these states to transition as needed. Below is a visual representation of the state machine.
I used the XState Visualiser to generate that image, for those interested.
The first connection I added to the dialogue system was the
on_continue event. When the user clicks the button or hits
Enter, it will emit a signal called
on_continue. I am then able to listen to this signal from the
InspectingTotem which will close the dialogue and transition back to
Wondering allow the player to continue walking down the path to the village.
The next connection I added was selecting a choice. Once I pass in my list of choices, I connect the button to a method that will emit a
on_choice_select event and pass along the node that has been select. This way I can perform specific actions based on which button was pressed. Overall pretty simple!
dialogueInstance.connect("on_choice_select", self, "_on_Dialogue_Choice") dialogueInstance.set_choices(["Pick up", "Ignore"]) func _on_Dialogue_Choice(choice_node: ToolButton): print(choice_node.text)
This is pretty much all that is needed to capture the player choice. Within the
_on_Dialogue_Choice method is where I will add the logic to perform specific things.
That is all I wanted to achieve today really. However, I got that done a lot quicker than I thought. What I will be doing next is trying to flesh out the rest of the map, add in the rest of the triggers and their base functionality to flesh out. Once that is done, I might work on a few small things on this website, been wanting to add in a rating system to the bottom of each devlog, not that this site gets much traffic.