Little Help for my Demo Math Game

HayaEdu

Villager
Member
Joined
Jul 15, 2018
Messages
6
Reaction score
1
First Language
Filipino
Primarily Uses
RMMV
I have problems with my simple math game. The answer for the operation is wrong; I think it did not go into one of the conditioning on my script. I think showing pictures is a better explanation.
I'm a beginner with things like this, but I think I have no big problem with the variables.
1.png
The problem is with this, having an issue with the conditioning.
2.png
Proof of the problem, the answer is just for testing.
3.png
 

Kuro DCupu

Trust me, I'm a veteran RMer
Veteran
Joined
Jul 6, 2014
Messages
480
Reaction score
1,467
First Language
Indonesia
Primarily Uses
RMMV
That's some pretty bizarre code...
If I want to cut it short :

event.PNG

Works pretty well this way. You don't even need to initiate the random value beforehand. I still can't figure why yours doesn't work. It looks fine tho.

Edit : Here's a copy :

Code:
var tary = [' + ', ' - ', ' * ', ' / '];
tary = tary[Math.randomInt(tary.length)];
var a = 1 + Math.randomInt(50);
var b = 1 + Math.randomInt(50);
$gameVariables.setValue(1, a.toString() + tary + b.toString());
$gameVariables.setValue(2, eval($gameVariables.value(1)));
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,087
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
@HayaEdu Kuro's solution looks sound; just as an explanation, I believe your plus variable is getting assigned incorrectly:
Code:
plus=$gameVariables.setValue(13,ope);
The setValue "function" is actually a method (JavaScript doesn't formally distinguish the two) without an explicit return value, meaning the plus variable remains undefined.

For future reference, you may find console.log() useful. To see how it works, make a simple map event with the following script call:
Code:
var test = $gameVariables.setValue(1, 2);
console.log('Value of test is now', test);
Press F8 during test-play to open the console window, then activate the event to see the message! Very useful when debugging. ^_^
 

HayaEdu

Villager
Member
Joined
Jul 15, 2018
Messages
6
Reaction score
1
First Language
Filipino
Primarily Uses
RMMV
Wow, thanks for helping guys! I learned something new today, will reply again if I finally solved it.

I finally did it, and I'm going to post another problem I have.
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top