What is a variable? Variables are data structures that can hold one piece of data while your game is running. They can hold either a number or a string. Custom variables are variables made by you or whoever.
There are two kinds of user variables
Global variables that exist across the entire game
Local variables which are defined in objects and only exist in-game within specific instances.
Creating them
There are many ways to create a variable. One is to use D&D by which you use the set variable buttion in the control tab.
Another way is to use GML(coding).
Ex(GML):
___________________________
chocolate=4
___________________________
If you want to know more PM me!
Names:
Variables can be up to 64 characters long im pretty sure. They can begin with a letter/number/underscore.
Decrementing:
Decrementing variables is to subtract one from a variable.
Ways:
________________________
chocolate -=1
________________________
chocolate = chocolate - 1
________________________
Incrementing:
Incrementing is to add 1 to a variable.
ways:
_______________________
chocolate +=1
_______________________ I prefer the first way
chocolate = chocolate + 1
_______________________
Wrapping:
This means you want a variable that only can have a value from 1 to 100. And it wraps it's value from 100 to 1.
if ( chocolate > 100 )
then chocolate = 1
if (chocolate < 1 )
then chocolate = 100
Drawing:
You can draw the value of a variable using GML(coding) function draw_text() or the Draw Variable action.
Any questions PM me....
There are two kinds of user variables
Global variables that exist across the entire game
Local variables which are defined in objects and only exist in-game within specific instances.
Creating them
There are many ways to create a variable. One is to use D&D by which you use the set variable buttion in the control tab.
Another way is to use GML(coding).
Ex(GML):
___________________________
chocolate=4
___________________________
If you want to know more PM me!
Names:
Variables can be up to 64 characters long im pretty sure. They can begin with a letter/number/underscore.
Decrementing:
Decrementing variables is to subtract one from a variable.
Ways:
________________________
chocolate -=1
________________________
chocolate = chocolate - 1
________________________
Incrementing:
Incrementing is to add 1 to a variable.
ways:
_______________________
chocolate +=1
_______________________ I prefer the first way
chocolate = chocolate + 1
_______________________
Wrapping:
This means you want a variable that only can have a value from 1 to 100. And it wraps it's value from 100 to 1.
if ( chocolate > 100 )
then chocolate = 1
if (chocolate < 1 )
then chocolate = 100
Drawing:
You can draw the value of a variable using GML(coding) function draw_text() or the Draw Variable action.
Any questions PM me....