MV Decimal notation input.

Hi community,

I'm working on an educational project to stimulate decimal notation for primary/middle school students. In some parts, I plan to pose a word math problem which expects a decimal number as a result.
Problem is the number input windown doesn't have a decimal point as an option.

1608336291178.png


I'd like to twitch it in order to have added the decimal point character ( . ) as an option alongside the 10 digits.
Something like this:

1608336410402.png


I'm sorry if there's already a solution, but I searched extensively and only found something related to having the currency as decimals.
I'm looking for either a snippet or a plugin, or even a pointer to where this window is in the js files so I can try and mess around with it.

Thanks in advance!
Found this bit of code inside Rpg_windows. My little knowledge tells me I'm sniffing the right place.

Window_NumberInput.prototype.changeDigit = function(up) {
var index = this.index();
var place = Math.pow(10, this._maxDigits - 1 - index);
var n = Math.floor(this._number / place) % 10;
this._number -= n * place;
if (up) {
n = (n + 1) % 10;
} else {
n = (n + 9) % 10;
}
this._number += n * place;
this.refresh();
SoundManager.playCursor();
};
Maybe I could hard code the point into the window, in a fixed position and use the integer value for the comparisons later.
while that is only 1 bit of the full code I think, you need to place 10 to 11,
but also code a way to set the "comma" or "period" to be selected.

this can require some coding to read this though.
Thank you for the insight @ShadowDragon !

A new thought: maybe reuse or adapt the name input procedure.
I use RS_InputDialog.js to gather input for a time telling event (e.g. 2:30). I have to then parse the inputted string to determine the hour and minutes, but for decimal notation, you probably wouldn't even need to parse. I do think you'd have to use some javascript for the inputted answer because RM's native variables only store integers. Maybe I'm wrong about this?
The plugin isn't cosmetically perfect. I'd love to see some css customization so that color, font, etc. could be modified, but it would at least get you to be able to grab an answer and continue working on your project while you were waiting for a solution more suited to your liking.

Just noticed you asked for MV. There is an MV version.
I use input form that can use any characters, so a conditional brach would be needed
to check either actor or string to see if it's correct, it uses a css file, but not yet been able
to recolor it or modify the look.

other than that, it works perfectly smoothly.
Thank you @Lady_JJ for taking the time!

That plugin definitely solves the problem for entering a decimal.

However, when it is assigned to a variable in Rpg Maker, it is automatically converted to integer, making the check buggy.

Then I came around this: https://forums.rpgmakerweb.com/index.php?threads/put-an-float-in-a-variable.70196/

This call

$gameVariables._data[1] = 0.04;

works on assigning a decimal into the variable.

I was trying to figure out how to combine this call with the plugin to have everything sorted.
I realized the input comes as a string, so I tried messin about the plugin to have it as float but I haven't got enough knowledge to do that.

Then I tried making the decimal with the "correct answer" a string. Instead of

$gameVariables._data[1] = 0.04;

I used

$gameVariables._data[1] = '0.04';

To check and it works!

I still feel there's more to it, though.
I am, at this point, going to defer to the more incredibly talented js scriptors of this forum. But, essentially, I think you could use this clumsy approach-

Using page 3 script command

define one js variable, e.g. jsVar1, to be a random number between 0 and 1 using the math.random function, multiply that by 10 or 100 or however many integers you want, truncate the trailing digits to however many digits you want, using js num.toFixed(2) where 2 is the number of digits you want. Assign that number to the variable using $gameVariables._data[1]=jsVar1

define a second js variable, e.g. jsVar2, to be another random number between 0 and 1 and do the same things to get your desired second number, $gameVariables._data[2]=jsVar2

Continue the script by adding a third js variable, e.g. jsVar3 to be the correct answer
var jsVar1=$gameVariables.value(1);
varjsVar2=$gameVariables.value(2);
varjsVar3=jsVar1+jsVar2;
$gameVariables._data[3]=jsVar3;
$gameVariables.setValue(3,jsVar3);

Again using page 3 script command, but a second event,
For the inputted answer, you would extract the answer captured using Buid's js, which I'm pretty sure is stored as a string, so use the text to string js function parseFloat("X")
Assuming you are storing the user answer in variable 5, it would be

var jsVar=$gameVariables.value(5);
var jsVar5=parseFloat(jsVar);
$gameVariables.data[5]=jsVar4;

and finally, for the 3rd event, you would compare variable(5) with variable(3)

I haven't tested this, but I'll see if I can put together a working event page.

Truly, though, I am going to bet (and hope) that someone else is going to jump in with a much more elegant solution. My js knowledge is truly of the absolute novice level.
So, in theory,this works

1608405275407.png


This assumes you have RS_InputDialog configured to capture the input into variable(4). You can change any of these numbers. What becomes a problem, though, is how to keep your math problem on the screen while capturing the input.
Thank you, that looks lovely, Imma try!

What becomes a problem, though, is how to keep your math problem on the screen while capturing the input.
I had not thought of that, well pointed.
I'll be keeping decimal numbers small, up to a hundred, so I suppose it'll be easy enough for kids to memorize and then answer.

Thanks again for your efforts.

ps.: if you are a "novice" and able to produce such code, what does that make me? LOL
I think kids need to be able to see the original problem to see why their answer was right or wrong. Heck, even as an adult, I don't always trust my memory. A picture does persist, so I use pictures. MZ has a great plugin called textpicture which will show your text as a picture. I don't see an equivalent for MV, but I'm sure you could probably use one of the HUD plugins.
I think kids need to be able to see the original problem to see why their answer was right or wrong.
Thanks for the heads up!

My idea is to provide feedback on the answer, if it is incorrect. Then the problem will show up again the payer will be able to try, at least 3 times. My idea is not punish wrong answers, but rather promote persistence. Well, it is a videogame!

With your help I've managed to create a working prototype. I hope to have an alpha for testing in the coming weeks.
if you need testing, I can help you out 🙂

Original thread: https://forums.rpgmakerweb.com/threads/decimal-notation-input.131147/