Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Setting variables when game starts for the very first time.

I have a handful of variables that i want to set as soon as my game starts for the first time.  Can this be done with a common event?  or do i need to tie them into the first event that is activated? (the begining story line npc)  They only need to be set once during the entire game. 
 
You'd either add them into the first event like you said, or set up a new event with all the changes in, set this to a parallel process, and have a new page on it with a condition that x switch is on. (Set x switch to on after all the variable changes).
 
In VX, can you set a Parallel Process event to run if a switch is OFF?

If you can, then yes, problem solved.  Otherwise, you'd need to turn the switch ON when the game starts.  Which would take an event.
 

Rliv

Member

Yeah, you can run a parallel event with a swith off, if it's a map event. However using a common event requires a switch for it to trigger. Just thought I'd get that out of the way. 

Now if you want the events to set and not add anymore as the game starts. You can do 1 of 2 things.

1.(Read this if your good with conditinal branches)
Make a Common event that sets all the values at the start, by making it Auto start, name your switch, then insert a conditional branch. Make the conditional branch state, that if this switch is on, set values to this. After you place in all your values place in switch off for the auto event. You should be able then toggle this command via F9 in the games debug mode. After making the event in common events, go to your map, make an event make sure it's auto start, and have that start the common event. Also be sure the common event switches off the map event. So you'll go back to your common event and place in the switch off map event switch. Or for the map event you can use a self switch to switch off the value switch.

2.(your other idea)
Create a map event which is set to auto at the start, and have that set the values for you, then after you can place in anything you want happening after it. Of course you'd want to create another page to stop it all, or you'll have a looping auto event.
 
You could modify the 'initialize' method of the Game_Variables class to look like:

Code:
  def initialize
    @data = []
    @data[1] = 12
    @data[10] = 1
    @data[51] = 100
  end

where all of the lines,  "@data[ x ] = n"
x is the variable number
n is the value you want to intialize it to.

they will only be set on "New Game"

Be Well
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top