MYSTERIES OF RPGMAKER?

Posts

What is this black magic?!

Labels where have you been my entire life...? I will definitely be using them from now on.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
I don't have a lot of good eventing tricks, but here's a good Script Call you can use without knowing anything about RGSS. It doesn't require importing a script or anything, just put this in a Script Call event command.

$game_self_switches[[$game_map.map_id, 22, 'B']] = false

This will set Self-Switch B of event 22 on the current map to false (also known as OFF). Now you can change one event's self-switches... from a different event! Change "false" to "true" if you want to turn the switch on instead.

Alternately:
$game_self_switches[[7, 22, 'B']] = false

This is an even more powerful version - you can change the self-switches of events on other maps. This will change Self-Switch B of event 22 on map 7 to OFF.

I do stuff like this to reset puzzles when leaving the room or dungeon. This way I can use self-switches even for complex puzzles. Which is good, because if I used regular switches, I would need several hundred of them per dungeon.
Here's a way to restore the variable pointer function from RPG Maker 2003 that was lost with RPG Maker XP. Just type in the event's script box:

$game_variables[<the number of the variable you want to change here>] = $game_variables[$game_variables[<number of the variable that holds the number of the variable you want to point to here>]]

So,
if Variable 1 is 9999, and
Variable 2 is 1,
And you want to set Variable 3 to whatever is in Variable 1,
$game_variables[3] = $game_variables[$game_variables[2]]
will set Variable 3 to 9999 via Variable 2.

This is handy when checking what's in a bunch of variables, because you can then change Variable 2 to some other number and quickly see what's in that variable.
I still don’t know what a Modulus does in the Variable Operations, nor have I ever used a Loop for anything.

I, like, many still prefer good ol’ trusty Labels for that.

author=Gourd_Clae
Labels where have you been my entire life...? I will definitely be using them from now on.

author=Darken
yeah they're good for jars




Oh, Darken, you so funny.
Modulus has a few useful functions that I'm only just learning about myself.

Modulus finds the remainder of a number after it is divided by a divisor. 65 modulus 10 is 5. (This is written as 65 %= 10 in Ruby. "%" is the modulus operator.) I first used this code to store up to 7 variables within a single variable in RPG Maker 2003; each digit of a 7-digit number became its own variable. It was possible to break the number up by using divide, then modulus.

After games become more math intensive, modulus can be used to even better effect. Finding the real angle of an angle value that has exceeded 360 degrees can be done by modulating it by 360 (real_angle = angle_value % 360).

Let's say you want a program in your game to run every time a variable reaches a multiple of 7. You can do this easily by making the condition, "if My Variable modulus 7 is equal to 0, then run this program." That's because there won't be a remainder when a multiple of 7 is reached.

It's a powerful tool, but it requires a math-intensive environment to come into its own. Perhaps someone with more mathematical experience can add to my examples above.
@ LockeZ

Damn o.O that does sound powerful indeed.... like, really..


What would you guys try, if you wanted to randomize something..? Like, call a random text from an NPC, or maybe even randomize if there is something to find in a treasure chest?
Can we ask/force the RPGmaker to pick a completely random number from let's say, a common event list, or, maybe better, jump to a random label or conditional branch in an event?
Marrend
Guardian of the Description Thread
21781
author=NebelSoft
What would you guys try, if you wanted to randomize something..? Like, call a random text from an NPC, or maybe even randomize if there is something to find in a treasure chest?
Can we ask/force the RPGmaker to pick a completely random number from let's say, a common event list, or, maybe better, jump to a random label or conditional branch in an event?


I've done it both through event commands (the random number option in "Control Variables", then "Conditional Branch"es based on the variable being randomized), and scripts (num = rand(X), a bunch of if/then statements, putting the results (yes, results can be text), into $game_variables[1]).

Fun fact: All the times I've done this, it was to emulate a Suikoden-style duel.
Rave
Even newspapers have those nowadays.
290
author=LockeZ
I don't have a lot of good eventing tricks, but here's a good Script Call you can use without knowing anything about RGSS. It doesn't require importing a script or anything, just put this in a Script Call event command.

$game_self_switches[[$game_map.map_id, 22, 'B']] = false

This will set Self-Switch B of event 22 on the current map to false (also known as OFF). Now you can change one event's self-switches... from a different event! Change "false" to "true" if you want to turn the switch on instead.

Alternately:
$game_self_switches[[7, 22, 'B']] = false

This is an even more powerful version - you can change the self-switches of events on other maps. This will change Self-Switch B of event 22 on map 7 to OFF.

I do stuff like this to reset puzzles when leaving the room or dungeon. This way I can use self-switches even for complex puzzles. Which is good, because if I used regular switches, I would need several hundred of them per dungeon.


Cool trick. Does it work for Ace, regular VX, XP or all above? Also it is cool as well since you can read one event's self-switches with conditional branch which make easier to do e.g. system where you get to choose from 3 chests but you can open only one (like in Mario 3's toad houses) without much of hackery. Will use it from now on. Thank you.

@Admins: Can it be pinned? Even if it after some time become inactive, it'll be still useful for new users.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
author=Rave
Cool trick. Does it work for Ace, regular VX, XP or all above? Also it is cool as well since you can read one event's self-switches with conditional branch which make easier to do e.g. system where you get to choose from 3 chests but you can open only one (like in Mario 3's toad houses) without much of hackery.
It works in all three versions of RPG Maker that support scripting.

And yeah, if you want to check an event's self-switches in a conditional branch, just change that = to == and stick it in the "script" section of the conditional branch, and you're good to go.

author=NebelSoft
What would you guys try, if you wanted to randomize something..?

You can set a variable to a random number, and then make conditons based on that variable. It's a built-in function of the Control Variables event command.


author=Addit
I still don’t know what a Modulus does in the Variable Operations

Zachary described what it does pretty well. Here are some actual times I've used it:

Showing a number on-screen with pictures - If you have a three-digit number, you need to show three pictures on the screen. How do you get the individual digits of a number? Well, first let's assume the number's in a variable. Then you need three more variables for each of the digits. We'll call these variable2, variable3, and variable4, for the ones, tens, and hundreds digits.
1) To get the ones digit, set variable2 equal to variable1, and then modulus variable2 by 10 to get just the last digit
2) To get the tens digit, set variable3 equal to variable1, modulus variable3 by 100 to get the last two digits, and then subtract variable2 from variable3 to get just the middle digit
3) To get the hundreds digit, set variable4 equal to variable1, and then subtract variable2 and variable3 from it to get just the first digit
4) If the original number was 578, then variable2 is now equal to 8, variable3 is now equal to 70, and variable4 is now equal to 500. You can divide variable3 by 10 and divide variable4 by 100 to turn them into the three numbers you should actually show on the screen.


Rounding a number - Let's say you want to round a number to the nearest thousand. Modulus is the easiest way to do this. Put the number you want in variable1, and you'll also need a variable2 to do the math.
1) Set variable2 equal to variable1
2) Modulus variable2 by 1000
3) Subtract variable2 from variable1

Modulusing the variable by 1000 asks, "If I divided by 1000, what would be remainder?" If your number was 36178, then the answer is 178. So then in step 3 you subtract that amount, 178, from the original number. Voila, you've just rounded down to get 36000 even.

("But that will always round down, even if the remainder is above 500. What if I want it to round up if it's closer to 37000?" Just add 500 to the variable before you start. "Wait, what? That works? Did you misunderstand me? That sounds like it wouldn't work." It works. Math, fuckers.)
@ LockeZ & Marrennd: OOoohhhh! o.o so THAT's what that can be used for... x.x
thanks for the clever idea guys, heh.. i learned something today. ^^
who would have ever guessed that math of all things would be useful??
Urgh.. my head is spinning. No wonder I don't use variables as often. I hate math. ><
RMN: Real Math Network.
Variables are invaluable. I actually did a bit of teaching on them the other day and we both came to the conclusion that variables >= switches in usefulness. ;p They're really versatile for all kinds of things - creating random events, creating menu systems, creating random encounter systems, creating randomly placed events/chests with random loot, keeping count of numbers, etc

Fucking useful as!
author=Liberty
Variables are invaluable. I actually did a bit of teaching on them the other day and we both came to the conclusion that variables >= switches in usefulness. ;p They're really versatile for all kinds of things - creating random events, creating menu systems, creating random encounter systems, creating randomly placed events/chests with random loot, keeping count of numbers, etc

Fucking useful as!

Definitely. Relationship values and a morality system are definitely a lot easier than you may think and you can do this even in RM2000. I don't even think the console RPG Makers had variables.
Yeah, I seriously need to use them more. Mainly I use them as little switches for event conditions/conditional branches ( I once made a very simple skill level up system akin to the original FF2 ages ago, without the excessive skill grinding ).

Besides, the real pros at using variables can make complete battle systems and menus and whatnot. Could be useful if the dev decides to go commercial and make a game without using a single script. =) Maybe some tutorials on that would be nice.
@ LockeZ – Oh, that’s what it’s used for. I had another method for doing what you described prior without using modulus, but this seems like a much easier way to do it than what I was doing before. Thanks, both of you. Now that solves that mystery for me.
There are tons already out there. The engine commands haven't changed so much from 2k/3 that the tutorials are no longer usable.
Wow, there are a ton of them. Why do I only see these tuts now. I like the look of narcodis' CMS tut. Gonna try it out. :D I do plan to make a game one day with just custom resources, and no scripts.
Making your own battle system is incredible fun. Everyone should try it.