Help - Search - Members - Calendar
Full Version: "Do This How Many Times?"
RPG RPG Revolution Forums > Game Engines > RPG Maker VX Discussion
Destinynite1
Alright. Here's the deal. In my project, I have a skill system. Now its tedious to have to say...cut gems by selecting the skill over and over and over just to get 15 or so gems. How could I use variable, cont. branches, etc. to have it repeat until you cancel or until you no longer have the item?

I tried a few different things but nothing worked
Sizux
I managed to create a system that works exactly how you described so I think you'll like it. You will need to make two events on the map.

Event 1:

Here is a picture of the event I made. Of course, yours may be slightly different, but this is just a general example.




I will explain all of the lines of code.

1: Text asking if the user wants to cut gems. Common stuff, really. Under it is a simple yes/no choice option.
2: This switch is used to tell the event that you want to cut gems. Basically, later in the program, you may want to cancel the gem-cutting process, which is where this switch will come in handy. More on that later.
3: Sets a variable to the # of uncut gems in the player's inventory. This is used to both display how many gems can be cut and to make sure the player doesn't get unlimited gems by checking when he runs out of uncut gems.
4: Checks to make sure the Cutting Process switch is ON. Yes, we did turn that switch on earlier in the event, but look up one line. Notice the Loop command. Everything below this will be ran multiple times, so that switch may be changed later. That switch is used to cancel the gem-cutting process and will be discussed later.
5: Makes sure the player has at LEAST 1 uncut gem in his inventory. Make sure you select the option "Equal to or Greater Than". When this condition is met, it will keep looping the event, but when it is not met (by having 0 uncut gems), it will be broken (see further below).
6: This removes 1 uncut gem, which will later be converted into a gem.
7: Yes, this was done in #3, but the variable MUST be updated since you removed an uncut gem in the last step.
8: This is the message the player will constantly see as the gems are being created. The "\v[1]" part simply displays the variable 1, which is the amount of uncut gems. The "\>" commands displays the following line instantly so the user can see the instructions easily. The "\|\^" is two commands: "\|" pauses the message for a second. This is used so the user has time to read the message. The "\^" command automatically exits out of the message without the user's input. That way, the user can go away from the keyboard while gems are being cut without having to skip the messages.
9: Adds a gem to the player's inventory which was made from the uncut gem.
10: This line is very important. This gives the player time to hold down shift (or whatever button the cancel is set to) before the loop is repeated. You can increase/decrease the time if you want, but it may cause some issues.
11: The message displayed when the player runs out of uncut gems.
12: This breaks the loop, ending the event.
13: The message displayed when you cancel the gem-cutting process.
14: This also breaks the loop, ending the event.





After that event is created, create a new event on the same map. Don't worry--this one is much easier.

Event 2:

This one is easy and doesn't require a picture. First, set the "Trigger" to parallel process. Then, check the first "Switch" box near the top and select the "Cutting Process" switch. Under the event commands, make a conditional branch and go to page 4. Check "Button" and select "A". The button A is shift on the keyboard and it is the button we'll be using. Hit OK. Under that conditional branch, make a switch that turns "Cutting Process" off.

That should work. It is pretty late here so I might not be able to respond to any problems you have for awhile, but this system should work if you have a good idea of how RPG Maker VX works.
Otaku Son
If you want to use Sizux's, great for you; it seems a bit too needlessly long, though.

Rather, after storing the number of uncut gems to v1, change it up so a message appears reading: "You have /v[1] uncut gems. How many gems would you like to cut?"
Then do a number input, store to variable 2.
If v2 is bigger than v1, error message.
Else, change uncut gems -v2, cut gems +v2.
Destinynite1
For some reason, I'm getting a script error. Its coming from the Game_interpreter.

CODE
actor = $game_actors[@parameters[1]]


'undefined method '[] for nil class'

What am I doing wrong? I have it set up the same way. I got the same thing on my project so I started a new one with no scripts. The normal default stuff and its giving me that error


EDIT: For some reason(it said parameters and everything else said params), I changed it from "parameters" to "params" and it works just fine now.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.