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.

Variables????

It's rather difficult to explain, so first let me direct you to this nice switch tutorial by missingno. If you don't know how to use switches, that should give you a good idea.

If/once you've mastered that, then we can move on to variables. Variables are basically switches with more than 2 options. Switches you can only turn ON or OFF, but variables can be set to any integer value (...-3, -2, -1, 0, 1, 2, 3.. etc). They're used if you want something to happen depending on more than 2 options.

For example, let's say you have a cutscene that you want to separate into four parts (pages). By using a variable, you can make this happen. Use the "Control Variables" option to add 1 each time a part ends. Then add a New Event Page. If you look at the "Conditions" area on the event page, you can see that there's a checkbox next to "Variable _____ is __ or above". If you select this choice, and set the variable to work at "1 or above", the page will only process if that variable is 1 or above.

There are other uses, this is just the basics. For example, you can add variables together, set them to coordinates or stat values, and many other things. All this can be done with the "Control Variables" command. Just play around with them. You can also look for other better variable tutorials if you'd really like to know all the functions.

Hope this helped.
 
A simple explanation:

If you are on a quest to feed a group of chickens on a farm, the farmer will flip a switch to allow you to open the cupboard where the chicken feed is.  However;  once you have all 10 handfuls of feed. (This is your feed variable. You'd add 10 after you get the feed.  Some people like to add 10 feed items also, which helps the player keep track of how many more chickens they need to feed.)  Now when you feed a chicken, you subtract one of your feed variables, leaving 9 and so on.  On your farmer event, you'd put an extra page with the conditional branch: Variable feed == 0  Under this condition, you'll put the end quest text, your reward for finishing the quest and so forth.  On the triggers part of the event, on the left of the event screen, you'd probably want it to ONLY activate when the feed quest switch is on.  (probably the same one that opened up the cupboard in the first place)  Then after your rewards, you'd turn that switch off, or you can use a self switch.  (They can simplify things at times.)

Anyway... If switches are used to turn lights on and off, then variables are the dimmer switches, or those lamps that have different brightnesses.  Basically, you use variables to set many options, like random weather, people's reactions, a player's good vs. evil meter, numbers of quest items, or even a kill count.  You'll use variables A LOT once you're more familiar with them.  The best thing to do is just experiment.  Tutorials are nice too.
 
I don't think a decent game can be made without variables. Also, I would use variables more often then switches just so you don't pile up your switch array and cause the game file to become huge.
 

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