General Question about Variable usage

Hey guys, so when I code a Drop Table for a boss, I use a variable "Boss Name Loot"

I have a different variable for each drop table, do I need to be doing this or can I just call the same variable everytime I want to roll a 1-25 RNG drop table sequence? I will provide screenshots of what I mean if I didn't make sense:

Sky Watcher Drop Table:
1644852143947.png


Frozen Guardian Drop Table:
1644852172482.png
Since the function of the variable is contained entirely to the event in which the random number is generated, there's no reason you can't reuse the same variable for all enemies.
@Trihan Wow.... that is actually crazy I didn’t know this haha this would have saved me a lot of mindless variable switching thru 100s of text lines
that depends on how long you want to store a result and where you want to use it.

if a variable is only used on a single command sequence in a single event, you can use a temporary variable (as in a variable named "temporary" to indicate that you should never assume it contains anything of value.

if you want to use a value in different events or in multiple runs of a looping event, then it is usually better to have it named and exclusive.
it is possible to use temporary variables even in some of such cases, but you need to be very sure of your logic and that nothing can interfere with it.
@Trihan Wow.... that is actually crazy I didn’t know this haha this would have saved me a lot of mindless variable switching thru 100s of text lines
Heh, it's an interesting moment when that clicks, for sure.

As Andar said, you would need to use a unique variable if you ever needed to refer to its value anywhere else in the game, but since it seems you're only using that variable to generate a random number for figuring out a loot item, and you're not using that value anywhere else other than that event, it would be considered a temporary variable.
Usually I name both variable #1 and switch #1 as "BLOCKED" and variables/switches #2 to #10 as "temp 1..9"

Too many functions default to ID 1 so I don't want that variable and switch in use anywhere to prevent surprises, and reserving the next nine for temporary use means I always have placeholders quickly when I need them.
I set aside the first block of 20 switches and several variables (with names like "control" and such) I use for cute eventing. I won't use them for storing long term information.

Original thread: https://forums.rpgmakerweb.com/threads/general-question-about-variable-usage.144930/