• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Help with coding if a variable is relative

R

ReytheN00B

Guest
Hey, I've been using Game maker for a while, and I've begun to develop practice games and such. So far, I have made a health system that uses purely code. I know that it is a little weird to not use the feature of drag and drop, but is there a way to make a variable relative or not through coding, instead?
 
G

guadalcanal

Guest
You want to declare a variable? Just do
Code:
myVariable = "I am a variable!"
If you just want to declare a variable only accessible in the event or script, you can do it like this:
Code:
var myVar;
var myOtherVar = 1;
myVar = 50;
Variables themselves are not relative or absolute. You can change them relatively by doing
Code:
variable (+ or * or - or / or %)=number
or
Code:
 variable = variable + amount
 
Last edited by a moderator:

FrostyCat

Redemption Seeker
I know that it is a little weird to not use the feature of drag and drop
I'd drop this misguided mindset right now if I were you. People who rely on drag-and-drop are the weird and marginalized ones around here, not people who use code. Most features of GMS are GML-only, and GML is the only format that makes practical sense for posting on a forum.
 
Top