K
Kululu17
Guest
Hey guys - this should be a really easy one for you pro programmers, but I seem to be beating my head against a wall. I want to set up the logic for a "generic" button object to change a variable in the game; for example changing some of the setup values, the map width, number of lives, whatever.
Setting up a button object that will change a specific variable is easy, and you can set up the button with default values, create a bunch of them and then reset the most of defaults using the 'with' command.... but the one thing I can't seem to figure out is a way to set/change the actual variable that I want to be changed.
For example in the create event you could put in
Value_Change = 1;
Min_Value = 1;
Max_Value = 10;
... and if you use the logic in the create event:
Value_To_Change = Variable_X;
Then you can set this using the with command for each instance created:
Button_1 = instance_create (100,100,OBJ_Btn);
with Button_1 {
Min_Value = 2;
Value_To_Change = Variable_Y;
}
This will change the parameters of that specific button... The problem is that for the variable you are trying to change, this just makes a copy of the current value of Variable_X (or Variable_Y), and then changes that value but doesn't push the changes from the step event, back to the underlying variable. Is there any way to code it so that you can reset the value to be changed
Thanks in advance!
Setting up a button object that will change a specific variable is easy, and you can set up the button with default values, create a bunch of them and then reset the most of defaults using the 'with' command.... but the one thing I can't seem to figure out is a way to set/change the actual variable that I want to be changed.
For example in the create event you could put in
Value_Change = 1;
Min_Value = 1;
Max_Value = 10;
... and if you use the logic in the create event:
Value_To_Change = Variable_X;
Then you can set this using the with command for each instance created:
Button_1 = instance_create (100,100,OBJ_Btn);
with Button_1 {
Min_Value = 2;
Value_To_Change = Variable_Y;
}
This will change the parameters of that specific button... The problem is that for the variable you are trying to change, this just makes a copy of the current value of Variable_X (or Variable_Y), and then changes that value but doesn't push the changes from the step event, back to the underlying variable. Is there any way to code it so that you can reset the value to be changed
Thanks in advance!