• 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!

GML Visual Declaring an instance variable in DnD

L

Leanthor

Guest
Hello, I'm new to GMS and I must be blind.

I can't find out how to declare an instance variable from the DnD interface, and the set instance variable function only gives me the built in list of instance variables.

Sorry if this is obvious, but thanks in advance for the assistance.
 

Tthecreator

Your Creator!
In game maker, you declare a variable when you first set it.
So just use the set instance variable function, then type in the name, and give it a value.
That's literally all you need to do. A good place to do this is the create event.
 
L

Leanthor

Guest
In game maker, you declare a variable when you first set it.
So just use the set instance variable function, then type in the name, and give it a value.
That's literally all you need to do. A good place to do this is the create event.
That's what I thought, however, when using the set instance variable function I'm unable to input my own variables, I can only choose from the built in list.
 

Tthecreator

Your Creator!
Mmm are you using gms1 or gms2? You said you used "set instance variable" but for me it just says "set variable". In gms2 it's called "assing variable"
 
L

Leanthor

Guest
Mmm are you using gms1 or gms2? You said you used "set instance variable" but for me it just says "set variable". In gms2 it's called "assing variable"
I'm using GMS2, I'll attach a picture of my "set instance variable" function. I only have access to a drop down menu of predefined variables.
 

Tthecreator

Your Creator!
You don't need that function. It literally only works on build in variables, that's what it's for. If you want to use it with your own variables, just use "assign Variable" as you've already been doing. You can use that function as many times as you like, on the same variable.
 

Perseus

Not Medusa
Forum Staff
Moderator
You're using the Set Instance Variable action (under the Instance action library) while you need to use the Assign Variable action (under the Common action library) here. The former allows you set values to built-in variables only, but the latter works for both built-in and custom ones.
 
L

Leanthor

Guest
Oh, thanks for the help guys, I really appreciate it. I was under the impression the Assign Variable action was a larger scope than the instance that created it.
 
Top