simple math puzzle

I want a person to have to remember the prices of items and add them up to come up with a total if they are wrong they have to start over how would I do that?
Are the prices variable or fixed? Is the puzzle random or fixed (i.e. does it just grab five items randomly out of the database, out of a pool of potential items, or is the question always the same five items)? How is the player inputting the answer (text, multiple choice, on screen numberpad)?
I want a person to have to remember the prices of items and add them up to come up with a total if they are wrong they have to start over how would I do that?
RPGMV_XJCBkfHz6T.png

RPGMV_UPyo6QsXzg.png

RPGMV_PUzocK5kmT.png



Here is the code for both the 1 to X number of items from the database and the pre-selected group for you to use.
Code:
var max = 50
var min = 1
var totalPrice = 0;
for (var i = 0; i < 5; i++) {
  var randomID = Math.floor(Math.random() * (max - min + 1) + min);
  if ($gameVariables.value(174).contains(randomId)) {
    randomID = Math.floor(Math.random() * (max - min + 1) + min);
  }
  $gameVariables.value(174).push(randomId);
  totalPrice += $dataItems[randomId].price;
}
$gameVariables.setValue(175, totalPrice);

Code:
var items = $gameVariables.value(174);
var totalPrice = 0;
for (var i = 0; i < 5; i++) {
  var randomID = items[Math.floor(Math.random() * items.length)];
  if ($gameVariables.value(174).contains(randomId)) {
    randomID = items[Math.floor(Math.random() * items.length)];
  }
  $gameVariables.value(174).push(randomId);
  totalPrice += $dataItems[randomId].price;
}

$gameVariables.setValue(175, totalPrice);

There is a way to do this without scripting but this is the fastest method that I can conceive of to skip the steps of eventing certain things painfully.
I figured it out i used labels it's the same numbers each time
If it's always the same numbers, labels are always helpful in that regard to just go back to the "Input Numbers" step.
I figured it out i used labels it's the same numbers each time
Then that would be like four lines of code in an if else statement because you would just be checking if a text input is equal to a fixed number.
One thing my event set up fails to do is properly assign item IDs to their own variables or to an array of the chosen items, thereby making it impossible to know which items the player needs to have price information on.
That's easy enough to fix, you would just have to create a new array in one more variable that's an array of the chosen items to refer to in text.
glad you figured it out.
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/simple-math-puzzle.156709/