The waiting state is also the one where we wait for user input, and update the output. We are going to do exactly what we described in 2.2 introduction :
To avoid conflicts with the other inputs of the game, User inputs are inactive on load. We just activate it when there is a choice dialog on the screen.
The last step to have a correct output is now to "start" this car, initialize the system. This is the function called in the "Start_Dialog" function. You know, the public one ;) As before, we will just set the variable right, and display the state (Display_choice). We will also need to activate the inputs.
2.2.2 Making the choice
The last thing we have to handle is the "Enter" input, making the choice. Depending on the choice selected when Enter is pushed, we will call the corresponding action in the CSV. What we need to do is define what those actions are.
Let's take a look back to the actions I wrote down :
- The last choice is supposed to do nothing. This doesn't require anything.
- The second choice is supposed to call the function "blink". This requires to just know the name of the function to call.
- The first choice is supposed to call a dialog. This requires to know the ID of the dialog.
If you take a minute to think about it, you can imagine other situations like the first choice, when you will want to call a function with a parameter. In this case, we want to call the public function Start_Dialog with the DialogID as a parameter, so the specified dialog will play. In a real game, you maybe would want to start a specific quest, or a specific script, or anything. So we need to be able to call a function and pass a parameter.
Based on this, we will want actions of those forms :
nameOfAFunctionToCall : blink
nameOfAFunctionToCall__Parameters : dialog__1
The events will use some string manipulation to look for the double underscore presence or not, and will call the "Action"&CurrentChoice function with or without parameters, depending :
And finaly, the actions implementations :
As this group of functions will always have to be re-written in your game, I put them together for simpler implementation.
The blink action will make the Start button blink. The function will be called without parameters.
The "dialog__1" action will call the function dialog with the parameter "1", witch will then call the Start_Dialog function with the parameter "1", witch will start the dialog ID 1 aka the "random" dialog.
2.3 Second part conclusion
Well, it doesn't seem like much, but the choice type is maybe the one you are most likely to use.
In the next part, we will focus on multiple points. First we will start by implementing this mod in a game. I'll use a prototype of mine as an example and will explain, step by step, how to do it in any project.
We will also expand on the output function. Instead of just putting out text, we will use spriteFont, add a speed of speech so the dialog isn't instant, and will see from here.
If you want to test the part 2, let's head over here.
If you have specific questions on how to implement this or that functionality, we will cover it, so feel free to ask, and discuss it over here.
This part was written trying to explain how to think a new functionality in this system, so if you have dialogs you could use it even if all the features you need are in it. One point I'll add in the future is the possibility to have multiple dialogs at once.
See you soon for 3rd part !