Closed ghost closed 2 years ago
Thanks! There is currently no such feature by default, but you can do it with JavaScript. The Window prompt() function displays an input dialog box. https://www.w3schools.com/jsref/met_win_prompt.asp
it can be used to enter a name or other data. here is an example of its usage for Tuesday JS https://github.com/Kirilllive/tuesday-js/blob/master/example/example_enter_name.json
You need to create a variable for the name in the project settings. The moment the player needs to enter a character name, execute that function in the "JavaScript" scene element (In the example, this is assigned to the button choise).
let person = prompt("Please enter your name:","User Name");
story_json.parameters.variables.(you var for name)=person;
You can then infer the character's name from the variable using angle brackets
I think I got it, thanks! But I have 2 issues, if for some reason they don't input anything can I set a default? (I tried with the pre-created variables but it doesn't work) - and this one is more for the flow of the gameplay, after inputing the name the player still has to click one more time to step forward to the next dialogue for some reason.
To automatically advance to the next dialog add go_story(true); or go_to('name block',true) if you need to move to another block. If the user clicks the Cancel button, you can check for null and provide a default name (person=="null")?person:"Default Name";.
let person = prompt("Please enter your name:","User Name");
story_json.parameters.variables.(you var for name)=(person=="null")?person:"Default Name";
go_story(true);
Thank you for the quick response, the auto advance works perfectly but for some reason whenever I have a person=="null"
in front of the prompt/variable change it won't pop up the user input.
I am mistaken, you need to change (person=="null") on (person)
YEP IT WORKED! Thank a lot for helping this quick and thank you for creating and continue developing this amazing engine!
Here is the final code for those interested:
let person = prompt("Please enter your name:","User Name"); story_json.parameters.variables.var_name=(person)?person:"Default Name"; go_story(true);
It's amazing how this engine has been and how constant the updates are for only 1 dev. Thank you.
Going to the point, is it currently possible to have a user input after a dialogue for example to change the "name" variable? If it's not could you please add it. It's something that I really need to make my project so the character would give a sense of closure to the player. Thank you once again!