GameMaker is there a way to hold a variable holding a value and not the value itself.

O

OriginalGrim

Guest
Is there any way that I can have another variable just hold another var as an empty var.
Code:
I = 2;
hold = noone;
hold0 = noone;
Code:
if keyboard_pressed_check(ord("N")) {
hold = I
hold0 = I(but not it's value just the I as an empty var)
}
 

jo-thijs

Member
Is there any way that I can have another variable just hold another var as an empty var.
Code:
I = 2;
hold = noone;
hold0 = noone;
Code:
if keyboard_pressed_check(ord("N")) {
hold = I
hold0 = I(but not it's value just the I as an empty var)
}
It is really adviced to not do this, as this tends to lead to very confusing code that in turn leads to harder project maintainance and more bugs.

However, yes, in GM:S 2 there is a way to do this using the variable_* functions:
https://docs2.yoyogames.com/source/_build/3_scripting/3_gml_overview/variable_functions/index.html
 
O

OriginalGrim

Guest
It is really adviced to not do this, as this tends to lead to very confusing code that in turn leads to harder project maintainance and more bugs.

However, yes, in GM:S 2 there is a way to do this using the variable_* functions:
https://docs2.yoyogames.com/source/_build/3_scripting/3_gml_overview/variable_functions/index.html
I'm trying to hold 2 values and the 2 variables that hold the values and then have the 2 vars that are held = whatever the others value was.
Code:
swap = false
holdval = noone;
holdval2 = noone;
holdvar = noone;
holdvar2 = noone;
Code:
if swap = false {
if keybored_check_pressed(ord("N")) {
holdval = val;
holdvar = var;
swap = true;
    }
}

if swap = true {
if keybored_check_pressed(ord("N")) {
holdval2 = val2;
holdvar2 = var2;
holdvar = holdval2;
holdvar2 = holdval; {
holdval = noone;
holdval2 = noone;
holdvar = noone;
holdvar2 = noone;
swap = false;
        }
    }
}
if there is a better way to do this I would very much like to know.
 
O

OriginalGrim

Guest
Top