Need help with turning a repetitive event into a Common Event

I've managed to finally create a custom level up system using variables, but, I realized that I'll be copying/pasting them in every rest event in battles maps. I want to turn it into a Common Event where I won't have trouble with it, but that might mean more tedious planning since I've made a custom token for leveling up using a variable:
Spoiler: This how it'd look if I'd copy/paste it in every event
1st page
Event01.png

Next page (Autorun) [SwitchA]
Event02.png

Next page [SwitchB]
Event03.png
I know one of the RPG Makers had a way to recall a certain event. You could always try that.
One approach would be to combine all of the levelup logic into a single common event page. Here's an example from one of my creations that checks 'Callus' (the equivalent of XP) :

Spoiler: Hands Up
hand_up.png

hands_up2.png

I believe you'd need to incorporate one additional switch or variable that reflects the current level (the equivalent of 'Has_Scuffed_H' and 'Has_Callused_H above) which verifies that the player doesn't yet have that level.

With that, you could have a single page that checks for Maintain_Mana, then takes the appropriate levelup action based on the current level and mana.

A Common Event may take some time to configure, but ultimately could save you a ton of time if you want to adjust the behavior at some point, and as you said when you create new rest events.

Also sorry if I'm misunderstanding your objective.
So... I'd create a long lost of conditional branches?
So... I'd create a long lost of conditional branches?

Exactly right! A single Common Event full of conditional branches, each handling one of the levels, each also checking for some switch/variable/condition indicating that the level hasn't yet been obtained, and that the prerequisites for the level exist.

Then, have your rest events reference the Common Even, which does the rest.

Good luck!!
I think I need a liiiittle help :LZSlol: :LZSlol:
So.. This what I've created so far:
Spoiler: Common Events
This is for the amount of level up tokens
CommonEvent02.png

This is for the amount of tokens needed if the player leveled up:
CommonEvent03.png

This is for requirements text if the conditional did not meet its requirements:
CommonEvent01.png
I feel like using a script for the player's level in conditional script would be easier .__.
Can you explain how this Mechanic plays out in the Game?
Iam not getting all the details of what shall happen while playing.
And is this after Battles or when talking to a NPC?`What are Tokens in this Scenario?
This is for collecting tokens (Mana, which it's a variable) after battles, depends on battles. Once they get, lets say, 150 Manas, they can use 100 as the price for leveling up.
This how it'd look like in the menu with Yanfly's Menu Variable:
027faef22cd6d87ffc560444f59e50e5.png
Here's an outline of what I was thinking:

level_up.png


So, a series of nested conditional branches which first check what the Level UP! value is, then check for sufficient mana, then take the level up steps if it's all good.

You'd just need to set the initial Level Up! value to '1' at the start of the game, you could use a parallel event on the starting map for this that flips to an empty page after doing so.

You may be right that a script would be easier, but I am alas not a great coder.

EDIT: In the second conditional branch, the Level UP! value would be changed to 3, rather than the 2 shown.
@Elliott404
Hey, Elliott

Maybe this can help you and you don't even need to configure each and every level up:

3 Variables:
ManaCurrently = stores the players current mana.
ManaToLevelUp = stores the amount of mana needed to level up.
ManaNeeded (optional) = shows the player how much more mana is needed to level up.

If your game does not have a flat mana curve, you can use this script call to do a custom mana curve:
$gameVariables.setValue(X, CURVE);

You can replace CURVE with any formula like this one:
$gameVariables.setValue(X, Math.floor($gameVariables.value(X) * 1.5));

X is the variable ID of ManaToLevelUp

With that formula the mana needed for each level up is increased by 50% each time.
level 1 = 100 mana
level 2 = 150 mana
level 3 = 225 mana
etc.
@akoniti Tried that in a new Common Event list (After disabling the current ones), nothing happens.

@ScorchedGround I've disabled the EXP since I don't need it, and I had problem with it that the minute the player gained EXP, it'll automatically level up without the variable needed so I've removed it. Thank you tho. I'll try it out.
Hmm? But I thought you wanted to put your leveling system into a common event right?

What I proposed there was made with your mana system in mind.
@akoniti Tried that in a new Common Event list (After disabling the current ones), nothing happens.

When you tested it, what were the Level UP! and Mana values? Remember, you'll need to set Level UP! to 1 at game start for this to work- if it's at 0 nothing will happen, since the Common Event begins by checking if its equal to 1.

I use the Debug tool included in this package to set and check things like var and switch values during testing:


EDIT: I'll also say that from the looks of it, @ScorchedGround has far greater engine and code knowledge than myself (as well as a hilarious signature)!
@ScorchedGround Sorry, I didn't see your reply till I've replied to akoniti. Now that I've tried your suggestion, it wasn't much effective. It kept the 150 Mana without leveling up.
EDIT: Hold up, I forgot to add something
EDIT2: Nope, nothing happened. I've definitely made an error:
Spoiler
ce.png

My knowledge of code is below amateur
@Elliott404
Just to make sure, are you going with a custom mana curve or a flat mana curve?

Because you seem to use both right now (one under a false variable ID).

Assuming you are using the custom curve, try this:
It does nothing but adding Mana :LZSlol:
Would you like for me to tell you how the system should work?
@Elliott404
Ok, let's play through the entire event, assuming that we have 127 mana and leveling up costs 100 mana.
Keep in mind, that you have to set the leveling cost for the first time (In this case 100) elsewhere.

Now, we call the common event:

#1 The conditional branch checks if we have enough mana -> 127 >= 100?
We do have enough mana, so we proceed to leveling up.
#2 We subtract the mana needed (100) from our 127 because we just spent 100 mana
#3 The message plays, saying how much mana we spent and how much we have left.
#4 Then we increase the amount of mana needed to level up again.
-> Assuming you are using my formula, the mana needed jumps from 100 to 150.
-> $gameVariables.setValue(X, Math.floor($gameVariables.value(X) * 1.5));
X is the variable ID of your Level UP! variable
#5 If you call the common event again, we have 27 mana left, but now leveling up costs us 150 mana.


#6 Else-branch:
This one is optional, we can calculate (for comfort) how much more mana the player needs to level up.
1. For that we set a third variable to 0.
-> that would be your \I[73]Next Lv.
2. Then we add the amount of mana needed for the next level up
-> \I[73]Next Lv. + \I[72]Mana
3. Then we subtract the amount of mana we have ; we get the amount we need to aquire to level up.
-> \I[73]Next Lv. - Level UP!
4. We play the message


Also Make sure all the variable ID's are correct, this is very important
it seems you swapped the variables in the script call, you need to put your Level UP! variable in there.

Edit: @Elliott404 Here is how it should look for you, But make sure to change all variable ID's to their correct ones. Try to make it 100% identical. (see the attachment)
Weird.. I did exactly as how you've instructed yet, nothing happens.
It just shows this, even after I've added a dummy event for the 150Mana:
iiii.png


EDIT: Yes, I've changed the Variables IDs
Could you send another screenshot of your event? Because it works perfectly for me.
I'll look if I can find any bugs.

Also just for my clarity, could you tell me which variable ID your "Level UP!" variable had?
Because that is not obvious from your previous screenshots and it could help me.

Edit: also I seem to have misread a previous statement you made:
Would you like for me to tell you how the system should work?
Please explain your system if you want to, it could help me aswell.
I thought you wanted me to explain what my common event was supposed to do.
Sure:
Spoiler: Event Editor
This event will be placed for several rest areas in battle map(s)
Event Editor.png
It used to be Var.05,07,09. I've changed them just now to Var50,51,52 for better solution.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-turning-a-repetitive-event-into-a-common-event.124773/