MV Check variable digits

I'm trying to get the digits value of a variable, example: var value is 25 and i want to get 5. How can i do this?
Why i want this? I'm calling pictures of numbers by script call
so you want a variable value to check if the number is 5?

like this conditional branch:

if: variable 4 = 5
show picture x
end

something like this? or something more complex?
because if you want a variable based on number, there was a thread how
to do that, but this also require the images to have a number in order to show.

but you need to explain a bit more in detail what you exactly want to achieve,
otherwise, you can go many ways, and probably my example isn't what you need.
Welcome!

See this:
What i want is more complex, that way i'll need like 1000 conditional branch or more. I'm using a script to show these pictures but if i want to show the pictures of the numbers with two digits or more i need to call another picture and it must have the value of the second digit that variable
so you want a variable value to check if the number is 5?

like this conditional branch:

if: variable 4 = 5
show picture x
end

something like this? or something more complex?
because if you want a variable based on number, there was a thread how
to do that, but this also require the images to have a number in order to show.

but you need to explain a bit more in detail what you exactly want to achieve,
otherwise, you can go many ways, and probably my example isn't what you need.
Plugin basic (checkVarDigit.js):
JavaScript:
function checkVarDigit(gamevar,pos){
    var chkvar=$gameVariables.value(gamevar);
    chkvar = chkvar.toString(); /*Convert in String*/
    chkvar = chkvar.split(''); /*Convert in Array*/
    return Number(chkvar[pos]);
}

How use (Variable 10 on Example):
Code:
if(checkVarDigit(10,1) == 2){
   alert("Equal");
}

Conditional Branch:
Code:
◆If:Script: checkVarDigit(10,1) == 2
   ◆Message: Hello!
   ◆
:End

Variable 10 with value 1245790
Pos 0 = 1
Pos 1 = 2
Pos 2 = 4
Pos 3 = 5
Pos 4 = 7
Pos 5 = 9
Pos 6 = 0
Im using this script call:

JavaScript:
$gameScreen.showPicture(32, 'num' + $gameVariables.value(61), 0, 10, 15, 100, 100, 255, 0)

Num is the picture, there are 10 (0 to 9) and $gameVariables.value(61) is the variable that i want the pictures of numbers show

Plugin basic (checkVarDigit.js):
JavaScript:
function checkVarDigit(gamevar,pos){
    var chkvar=$gameVariables.value(gamevar);
    chkvar = chkvar.toString(); /*Convert in String*/
    chkvar = chkvar.split(''); /*Convert in Array*/
    return Number(chkvar[pos]);
}

How use (Variable 10 on Example):
Code:
if(checkVarDigit(10,1) == 2){
   alert("Equal");
}

Conditional Branch:
Code:
◆If:Script: checkVarDigit(10,1) == 2
   ◆Message: Hello!
   ◆
:End

Variable 10 with value 1245790
Pos 0 = 1
Pos 1 = 2
Pos 2 = 4
Pos 3 = 5
Pos 4 = 7
Pos 5 = 9
Pos 6 = 0
You can do this with variable operations alone:
  • Div returns the result after dividing by the operand, rounded down to the nearest integer;
  • Mod returns the remainder after dividing by the operand.
Together these can be used to get the value of any digit, e.g.

◆Text:None, Window, Bottom : :Enter a number! ◆Input Number:Count, 3 digits ◆Control Variables:#0017 check = Count ◆Control Variables:#0017 check %= 10 ◆Text:None, Window, Bottom : :Units digit is \v[17] ◆Control Variables:#0017 check = Count ◆Control Variables:#0017 check /= 10 ◆Control Variables:#0017 check %= 10 ◆Text:None, Window, Bottom : :Tens digit is \v[17] ◆Control Variables:#0017 check = Count ◆Control Variables:#0017 check /= 100 ◆Control Variables:#0017 check %= 10 ◆Text:None, Window, Bottom : :Hundreds digit is \v[17]

[Edit: whoops, I should have checked the link Dev_With_Coffee posted before replying. 😴]
JavaScript:
$gameScreen.showPicture(32, 'num' + $gameVariables.value(61), 0, 10, 15, 100, 100, 255, 0)

Try this:
JavaScript:
$gameScreen.showPicture(32, 'num' + checkVarDigit(61,1), 0, 10, 15, 100, 100, 255, 0)
Thank you two guys!
Or this:
Welcome!

See this:

Example with 4 digits:
Code:
◆Comment:---------------------------------------------------------
◆Control Variables:#0062 A*** = Var #0061
◆Control Variables:#0063 *B** = Var #0061
◆Control Variables:#0064 **C* = Var #0061
◆Control Variables:#0065 ***D = Var #0061
◆Comment:---------------------------------------------------------
◆Control Variables:#0062 A*** /= 1000
◆Control Variables:#0063 *B** /= 100
◆Control Variables:#0064 **C* /= 10
◆Comment:---------------------------------------------------------
◆Control Variables:#0062 A*** %= 10
◆Control Variables:#0063 *B** %= 10
◆Control Variables:#0064 **C* %= 10
◆Control Variables:#0065 ***D %= 10
◆Script:$gameScreen.showPicture(31, 'num' + $gameVariables.value(62), 0, 10, 15, 100, 100, 255, 0)
◆Script:$gameScreen.showPicture(32, 'num' + $gameVariables.value(63), 0, 20, 15, 100, 100, 255, 0)
◆Script:$gameScreen.showPicture(33, 'num' + $gameVariables.value(64), 0, 30, 15, 100, 100, 255, 0)
◆Script:$gameScreen.showPicture(34, 'num' + $gameVariables.value(65), 0, 40, 15, 100, 100, 255, 0)

Original thread: https://forums.rpgmakerweb.com/threads/check-variable-digits.139899/