Question how do i use varibles and sitchwes? (Read 268 times)

  • Group: Member
  • Joined: Nov 4, 2009
  • Posts: 2
I really wanna know cuz my cuzin is making game and i need to learn the stuff
  • Avatar of Corfaisus
  • Cold-Souled Sovereign of the Night Blades
  • PipPipPipPip
  • Group: Member
  • Joined: Oct 24, 2008
  • Posts: 463
A good way to use switches would be for:

• Chests that can only be opened to obtain treasure once
• Unlocking doors
• Quest Giver NPCs and main quest important NPCs

These are fairly easy to use. For chests, make an event with a treasure chest graphic and use a move event (optional) command to show that the chest has opened. Now you can include a message saying what you found, and increase the amount of an item that the player possesses, or money they are holding. After this message and obtaining the treasure, make a second page that comes into play after a switch has been turned on. You can either leave this page blank, or write a simple message such as "The chest is empty." To apply the second page, there should be an area to the top left corner of the event box that says something along the lines of "Preconditions" with a few choices such as "If (switch) is ON".

Variables are a tad bit trickier, but can be used to a much greater extent than switches. These simply work by giving a value to said variable and different events doing different things at said value. A very simple yet interesting way to use variables would be to make:

• Banks to store items/gold
• Clock to show how long the player has been playing

To make a simple clock item, make a common event and set it to "Parallel Process". Within this event, place the following...

<> Wait 1.0 Sec
<> Variable Oper: [0001: Seconds] + , 1
<> Branch if Var [0001: Seconds] is 60 or more
  <> Variable Oper: [0002: Minutes] + , 1
  <> Variable Oper: [0001: Seconds] - , 60
  <> Branch if Var [0002: Minutes] is 60 or more
    <> Variable Oper: [0003: Hours] + , 1
    <> Variable Oper: [0002: Minutes] - , 60

After this, make another common event, and set it to "Auto Start" with a trigger switch such as "###Clock###". Make an item that turns on this switch and set it to unlimited use. Inside this common event, place something such as...

<> Message: You have been playing for...
                      \v[0003] hours, \v[0002] minutes, and \v[0001] seconds.

The "\v[####]" in RPG Maker displays the value stored in the variable sharing the number placed between [  ].
Last Edit: November 04, 2009, 04:44:28 am by Corfaisus