Hello all, first of all sorry for my bad English, I'm a primary school teacher and trying to make an educational RPG game (basic English exercises) for my students.
Instead of using the "choices" command from the engine itself, I'm been using the "Keyboard Input Dialog" plugin by Biud436 (Credits to Biud436) which you can find from here : - http://biud436.tistory.com/58
Everything's been working fine until I realized if I click OK without text in the keyboard input, it will crash and gives error.
I don't have any basic on scripting so kindly seeking help out here.
1. When answering a question:
[embedded media]
2. If click OK without any text in the input:
[embedded media]
3. The plugin:
4. Original plugin can be found from:
http://biud436.tistory.com/58
Trouble with Keyboard Input Dialog plugin by Biud436
● ARCHIVED · READ-ONLY
-
-
Can you please post a screenshot of the Console with the full error message? The Console can be opened by pressing F8 during a playtest.
It looks like the author of this plugin is still active, so you might be able to find some support by asking here:
https://forums.rpgmakerweb.com/index.php?threads/keyboard-input-dialog.66908/ -
Can you please post a screenshot of the Console with the full error message? The Console can be opened by pressing F8 during a playtest.
It looks like the author of this plugin is still active, so you might be able to find some support by asking here:
https://forums.rpgmakerweb.com/index.php?threads/keyboard-input-dialog.66908/
Do you mean this?
-
Do you mean this?
I think that the problem is in Conditional Branch. if the Conditional Branch is executed, it will have to be evaluated to true or false. However, if you have the error, it means that there is something wrong in the corresponding expression. -
I think that the problem is in Conditional Branch. if the Conditional Branch is executed, it will have to be evaluated to true or false. However, if you have the error, it means that there is something wrong in the corresponding expression.
Thanks for the response, I tried double checking the Conditional Branch, but everything seems ok to me.
Do you mind to check for me?
It works fine as long as I type anything in the input, correct / wrong answer, but if I click OK directly without typing anything, it'll cras.
-
This is actually because of a behavior in RPG Maker MV that is not obvious.
Explanation:
1.) Normally variables hold integers, like 1, 2, 3, etc.
2.) These variables can also hold strings, like 'HAVE'. Here is the tricky part, it can even hold empty strings. Empty strings look like this: ''
It's a string, but it's totally empty.
3.) In Javascript, an empty string is a falsy value. Other falsy values are 0, false, undefined, null.
4.) When you get the value of the variable using $gameVariables.value(3) it uses this function:
Code:Game_Variables.prototype.value = function(variableId) { return this._data[variableId] || 0; };
5.) What that means is if the value is falsy (like an empty string), instead of giving the string it gives 0 (zero)
6.) Zero is a number, not a string, so it does not have a method called .toLowerCase()
This is why the error happens "undefined is not a function", because .toLowerCase() can't be used on numbers.
Suggestion:
You can change the conditional branch check to this:
Code:It should solve your problem. What it means is first check if the value is truthy (not empty) and then check if it is the correct answer.$gameVariables.value(3) && $gameVariables.value(3).toLowerCase() === 'have' -
This is actually because of a behavior in RPG Maker MV that is not obvious.
Explanation:
1.) Normally variables hold integers, like 1, 2, 3, etc.
2.) These variables can also hold strings, like 'HAVE'. Here is the tricky part, it can even hold empty strings. Empty strings look like this: ''
It's a string, but it's totally empty.
3.) In Javascript, an empty string is a falsy value. Other falsy values are 0, false, undefined, null.
4.) When you get the value of the variable using $gameVariables.value(3) it uses this function:
Code:Game_Variables.prototype.value = function(variableId) { return this._data[variableId] || 0; };
5.) What that means is if the value is falsy (like an empty string), instead of giving the string it gives 0 (zero)
6.) Zero is a number, not a string, so it does not have a method called .toLowerCase()
This is why the error happens "undefined is not a function", because .toLowerCase() can't be used on numbers.
Suggestion:
You can change the conditional branch check to this:
Code:It should solve your problem. What it means is first check if the value is truthy and then check if it is the correct answer.$gameVariables.value(3) && $gameVariables.value(3).toLowerCase() === 'have'
This is WORKING!
Thanks a lot for the great explanation, helpful and being patient with me.
Guess I need to start taking classes.
Another question, the LowerCase part, how do I change it to case sensitive? For example:
Question: _ am playing football.
Answer: I (capital letter, case sensitive)
Thanks and regards :ehappy: -
To do a case-sensitive check, all you have to do is get rid of .toLowerCase()
Then if the answer was:
I === I // true, correct answer
Or:
i === I // false, incorrect answer -
To do a case-sensitive check, all you have to do is get rid of .toLowerCase()
Then if the answer was:
I === I // true, correct answer
Or:
i === I // false, incorrect answer
Thanks a lot for your patience and guidance!
Everything's good now!
Will credit both of you :elhappy:
@Aloe Guvner
@biud436