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.

I don't understand variables at all

variables are just like switches, with the difference that switches can only be "on" of "off" while variables can be asigned any number, so for example you make it after a long dialogue, the variable "npcdialogue" changes to 1, if you talk to the npc again and put in the condition tab "variable npcdialogue = 1" then somethung different may happen, and if the variable is equal to 2 something more will happen too, that way you can have an event have multiple pages without having to make tons and tons of switches.
 

Kraft

Sponsor

A variable is basically a number-storer.  It saves a certain number for you until you change it.

For example, the amount of gold that your party has is a variable.  It can go up and down depending on what you do to it (spend, or earn)

That is how variables are.  Number-storers.
 
Here's a response to the "What's a variable?" question I posted at Amaranthia.com....
(originally posted here, but the image link is broken, and it's closed.)

From a beginning programming manual:

A variable is used to hold data within your program. A variable represents a location in your computer's memory. You can put data into this location and retrieve data out of it. Every variable has two parts, a name and a value. (NAME = value)

Think of a variable as a yellow sticky note (Post-It).

Let's say you want to keep track of the number of times your sister says the word, "like".

On the top of your sticky, write in pen "Sister_Like". THis is the NAME of our variable.
Put a big black line under it.

Now in pencil, write "0" on the bottom part.

http://home.comcast.net/~bridge161/sister_like.png[/img]

Now, everytime your sister says, "Like", erase the number, add 1, and write the next number.
([0001: Sister_Like] += 1)

At any time, you can check the value to see how she's doing. Just look at the note NAMED: Sister_Like

Now let's say you have a rule... every 100 times, she needs to be slapped!
You could use the logic in your program:

@>Conditional Branch: Variable [0001: Sister_Like] == 100
. @> Call Common Event: Slap_Sister
. @> Control Variables: [0001: Sister_Like] = 0
:
@>



Does that help? Too simplistic? Or were you looking for a more technical explanation?


Be Well
 
Brewmeister":3n846m7y said:
Here's a response to the "What's a variable?" question I posted at Amaranthia.com....
(originally posted here, but the image link is broken, and it's closed.)

From a beginning programming manual:

A variable is used to hold data within your program. A variable represents a location in your computer's memory. You can put data into this location and retrieve data out of it. Every variable has two parts, a name and a value. (NAME = value)

Think of a variable as a yellow sticky note (Post-It).

Let's say you want to keep track of the number of times your sister says the word, "like".

On the top of your sticky, write in pen "Sister_Like". THis is the NAME of our variable.
Put a big black line under it.

Now in pencil, write "0" on the bottom part.

http://home.comcast.net/~bridge161/sister_like.png[/img]

Now, everytime your sister says, "Like", erase the number, add 1, and write the next number.
([0001: Sister_Like] += 1)

At any time, you can check the value to see how she's doing. Just look at the note NAMED: Sister_Like

Now let's say you have a rule... every 100 times, she needs to be slapped!
You could use the logic in your program:

@>Conditional Branch: Variable [0001: Sister_Like] == 100
. @> Call Common Event: Slap_Sister
. @> Control Variables: [0001: Sister_Like] = 0
:
@>



Does that help? Too simplistic? Or were you looking for a more technical explanation?


Be Well
I kind of get it, but how does the game know what it is supposed to be counting?  I didn't really see that, unless I'm just blind :p
 

Injury

Awesome Bro

Well, the control variable feature offers a lot of different ways to interpert the variable. You can set it to a static number, or have it increase/decrease over time. By using a Fork Condition, you can ensure that when you change the variable, certain events will notice if you tell them too via the Variable Start: 001:Bell Rings, or whatever.
 
Well, you can set the variable to the players gold or x/y coordinates, but other than that the game does not know what it is counting. You know what it is counting. That is why you name the variable something that you know of.

Think of a variable, as a switch, but with infinite positions.

They are a good way to reduce the number of switches you use in your game.

-Syv
 
For example...

You want the game to store how many npcs you talk to.

Create a variable called npc_talk. Then, make your character talk to any npc. At the end of the code of the npc talk, make the variable npc_talk get added 1. Which means, each time you talk to an npc, that variable gets +1.

Then, you can make an event that makes you show how many npcs have you talked to, and you show that by showing the npc_talk variable.

hope you get it ToT

EDIT: The variable counts whatever you want ;P
 

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