Store Common Event in Variable and call it later

Basically i want something like this:

var foo = common event;

run(foo);

Is this possible?

I need that because foo can have diffrent Common events.
$gameTemp.reserveCommonEvent(ID)
$gameTemp.reserveCommonEvent(ID)
But doesnt this call the event immediately?

I want to call the event later on, but not when i assign it.
Thanks for the quick reply tho.
But doesnt this call the event immediately?

I want to call the event later on, but not when i assign it.
Thanks for the quick reply tho.
Why would you need to assign it before you call it?
Why would you need to assign it before you call it?
Well i have multiple unique sources where i assign these variables and one general "processor", who handles everything. The processor is basically all my shared code, so it needs to be flexible
Well i have multiple unique sources where i assign these variables and one general "processor", who handles everything. The processor is basically all my shared code, so it needs to be flexible
In that case, why not assign the common event ID to a game variable and then use the variable's value in the call to reserveCommonEvent when you need to call it?
In that case, why not assign the common event ID to a game variable and then use the variable's value in the call to reserveCommonEvent when you need to call it?
Im not sure how that would look. Can you give me an example?
JavaScript:
$gameTemp.reserveCommonEvent($gameVariables.value(123));
"Reserve the common event with ID equal to the value of game variable 123".
Im not sure how that would look. Can you give me an example?
Exactly as caethyril said.
JavaScript:
$gameTemp.reserveCommonEvent($gameVariables.value(123));
"Reserve the common event with ID equal to the value of game variable 123".
Well okay i think i got it. Thank you all for your quick help.
Well okay i think i got it. Thank you all for your quick help.
Okay so something weird is happening.

I have a loop after the "$gameTemp.reserveCommonEvent($gameVariables.value(123));" script
And now it doesnt work. When i remove the loop everything works fine, but with the loop it doesnt.
@IareaGuys, please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.
@IareaGuys, please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.
Ah okay sorry. I wasnt sure what to do since it has to do with the other things. I'll make a new post
It’s OK to have a follow up question, double posting is just posting twice in a row. You can always edit your most recent post with additional information and @ anyone you’re trying to follow up with.
Okay so something weird is happening.

I have a loop after the "$gameTemp.reserveCommonEvent($gameVariables.value(123));" script
And now it doesnt work. When i remove the loop everything works fine, but with the loop it doesnt.
What does your full event page look like? It might be stuck repeating whatever is in the loop
It’s OK to have a follow up question, double posting is just posting twice in a row. You can always edit your most recent post with additional information and @ anyone you’re trying to follow up with.
Ahh okay thats what you meant. Thank you for the clarification
Okay so something weird is happening.

I have a loop after the "$gameTemp.reserveCommonEvent($gameVariables.value(123));" script
And now it doesnt work. When i remove the loop everything works fine, but with the loop it doesnt.
What does your full event page look like? It might be stuck repeating whatever is in the loop
Well my code looks basically like this.

Control Variables: #0001 Eventcaller = $gameTemp.reserveCommonEvent($gameVariables.value(1));
Loop

repeat above
Well my code looks basically like this.

Control Variables: #0001 Eventcaller = $gameTemp.reserveCommonEvent($gameVariables.value(1));
Loop
repeat above
You're setting Control Variable 1 to a function calling Common Event #(value of the control variable itself).

The control variable should just be storing a number value. Then later call $gameTemp.reserveCommonEvent($gameVariables.value(1)); in a separate script call when you want the common event to run
Ahh okay thats what you meant. Thank you for the clarification

Well my code looks basically like this.

Control Variables: #0001 Eventcaller = $gameTemp.reserveCommonEvent($gameVariables.value(1));
Loop

repeat above
Yeah, this is basically a circular reference where you're trying to set the value of a variable to a line of code that references its own value. As AquaEcho said, you'd put the *common event ID* into variable 1, and then the code line will call the common event with the ID stored in the variable.

Original thread: https://forums.rpgmakerweb.com/threads/store-common-event-in-variable-and-call-it-later.158748/