Show different picture depending on the previous picture shown

Let's say I want to make a journal, I'm gonna name all the pages something like "journal1" "journal2" "journal3"

And to show them all in succession, instead of having a million different commands that say "when right arrow is pressed show picture 'journal1'" "when right arrow is pressed show picture 'journal2'" I'd rather use a script call somewhat like "when right arrow is pressed, show picture 'journal[x+1]'" so it would automatically switch it to the "next" page
How would I go about it? Or would I need a separate variable to store the current [x] value in?
Have you checked out Hiddenone's tutorial? She uses variables for this.
I'd definitely go for using a variable here.

I've done something similar before with a treasure eggs. What I did was create a Variable that I named "Current Egg" and used a Loop with Conditional Branches depending on the left/right button being pressed. Thing is, I only had 10 eggs. So once you reached the 10th egg, and try to go past it, I would also set additional conditions within the loop for the variable itself, and it would just cycle back around to the 1st egg.
All it really is is adding or subtracting a value of 1 per button input. But I wanna note, make sure you include a slight frame wait so that there's no lag. Like 3 frames after a button is pressed.

Code:
Control Variable (Current Egg) = 1

Loop{

If Player presses Right Button:{
Control Variable (Current Egg) +1
Wait 3 frames
}

If Player presses Left Button:{
Control Variable (Current Egg) -1
Wait 3 frames
}

If Current Egg > 10:{
Set Current Egg = 0}

If Current Egg < 1:{
Set Current Egg = 10}


}
Have you checked out Hiddenone's tutorial? She uses variables for this.
I took a look at the tutorial just now, and unfortunately it's not quite what I'm looking for coding-wise since I already know how to do this sort of thing. Thank you though.

Code:
Code:
Control Variable (Current Egg) = 0

Loop{

If Player presses Right Button:{
Control Variable (Curreny Egg) +1
}

If Player presses Left Button:{
Control Variable (Current Egg) -1
}

If Current Egg > 10:{
Set Current Egg = 0}

If Current Egg < 0:{
Set Current Egg = 10}


}

This isn't quite what I'm looking for either, but thanks again.

Sorry if I seem picky <<; What I'm hoping to find is a script call that can state "when right arrow is pressed, show picture 'journal[x+1]'' and ''when left arrow is pressed, show picture 'journal[x-1]'', not alternate coding solutions.
You can find the list of script calls and examples here: https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-mz-script-call-list.46456/, the relevant one being
JavaScript:
$gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode);

I didn't test the following but since you have some idea of what you're doing, I'll just lay out the rough idea - I'd probably set a variable equal to 1 (or whatever the start of your journal is) at the start, show that picture, then use a combination of event commands (similar to what @PoptartPresident used for the player's input), and script calls incorporating that variable to accomplish what you need.

For example, when the player presses the Right button, increment the variable (let's say it's variable 10) by 1. Then use the script call
JavaScript:
const pic = 'journal' + $gameVariables.value(10);
$gameScreen.showPicture(pic, ...);
where ... indicates all the other arguments you need to enter for the showPicture function.

I would also erase the previous picture as I move to the new picture. I personally think it's easier to use the event command for "if player pressed Right button" than use the script call for it, but the same document also has the script call for Input.isPressed (or isTriggered, depending on what you want).
You can find the list of script calls and examples here: https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-mz-script-call-list.46456/, the relevant one being
JavaScript:
$gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode);

I didn't test the following but since you have some idea of what you're doing, I'll just lay out the rough idea - I'd probably set a variable equal to 1 (or whatever the start of your journal is) at the start, show that picture, then use a combination of event commands (similar to what @PoptartPresident used for the player's input), and script calls incorporating that variable to accomplish what you need.

For example, when the player presses the Right button, increment the variable (let's say it's variable 10) by 1. Then use the script call
JavaScript:
const pic = 'journal' + $gameVariables.value(10);
$gameScreen.showPicture(pic, ...);
where ... indicates all the other arguments you need to enter for the showPicture function.

I would also erase the previous picture as I move to the new picture. I personally think it's easier to use the event command for "if player pressed Right button" than use the script call for it, but the same document also has the script call for Input.isPressed (or isTriggered, depending on what you want).
Yes! That's exactly what I'm looking for, I'll give that a go now~ Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/show-different-picture-depending-on-the-previous-picture-shown.158809/