• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Variable_global_get ?

gnysek

Member
I've just tried variable_xxx_exists function in latest release, and looks, that they don't work.

There's a simple object in game:
Code:
//create
    global.test = 1;
    local_test = 1;

//draw event
    draw_text(10, 10, variable_instance_exists(id, "local_test") ? "1" : "0");
    draw_text(10, 30, variable_global_exists("test") ? "1" : "0");
However, on screen I'm getting "0" and "0".

Is this broken on latest release or am I doing something wrong ?
 

DukeSoft

Member
Hmz, are you sure the names shouldn't be literal pointers then, not strings? Because I figure a lot of info like variable names gets lost when compiling.. Don't know for sure, I'm runnning 1.4 :)
 

gnysek

Member
Hmz, are you sure the names shouldn't be literal pointers then, not strings? Because I figure a lot of info like variable names gets lost when compiling.. Don't know for sure, I'm runnning 1.4 :)
Then please stop answering on something, you have no idea.... or just read the manual:

variable_global_exists - http://docs2.yoyogames.com/source/_...ariable_functions/variable_global_exists.html
variable_instance_exists - http://docs2.yoyogames.com/source/_...iable_functions/variable_instance_exists.html

There's no references in GMS:2, so if passing without " " I would get value instead.
 

DukeSoft

Member
I'm sorry for trying to help you man. Its only now that I see its in the subforum GM:S2.

Also, in this case, you should file a bug.
 

GMWolf

aka fel666
Gms2 has a few type casting issues.
Make sure to wrap your values in string().
That could be your problem.
 

gnysek

Member
Also, in this case, you should file a bug.
I would like to see if others also have this issue, cause maybe it's something on my side.

Gms2 has a few type casting issues.
Make sure to wrap your values in string().
That could be your problem.
Code:
draw_text(10, 10, variable_instance_exists(object_0, string("local_test")) ? "1" : "-");
    draw_text(10, 30, variable_global_exists(string("test")) ? "1" : "-");
Doesn't help, also typeof("test") returns "string" so it's for sure string.
 

GMWolf

aka fel666
I would like to see if others also have this issue, cause maybe it's something on my side.



Code:
draw_text(10, 10, variable_instance_exists(object_0, string("local_test")) ? "1" : "-");
    draw_text(10, 30, variable_global_exists(string("test")) ? "1" : "-");
Doesn't help, also typeof("test") returns "string" so it's for sure string.
I meant draw_text takes a string. Try this:
draw_text(10, 30,string(variable_global_exists("test")));
Coupd fix it. I have had similar issues before...
Ofc it could just be that the function doesn't work.
 

gnysek

Member
I've also tried with show_debug_message and result is same, so it's probably broken. Sadly, won't get fix since weekend is coming in several hours...
 

Alice

Darts addict
Forum Staff
Moderator
Experiencing similar issues over here. I tested with show_debug_message on Created event, and here are the results:
Code:
x = 1054;    // built-in variable
zzz = "aaa";    // local variable
global.zz = "bbb";    // global variable

show_debug_message(variable_instance_exists(id, "x"));      // shows "1", as it should
show_debug_message(variable_instance_exists(id, "zz"));     // shows "0", as it should, but...
show_debug_message(variable_instance_exists(id, "zzz"));    // shows "0", even though zzz has been initialised

show_debug_message(variable_global_exists("x"));      // shows "1"
show_debug_message(variable_global_exists("zz"));     // shows "0", as it shouldn't
show_debug_message(variable_global_exists("zzz"));    // shows "0", as it should, but the previous result is wrong

show_debug_message(variable_instance_get(id, "x"));    // shows "1054"
show_debug_message(typeof(variable_instance_get(id, "zzz")));    // shows "unknown"
@gnysek: have you reported the bug, or have yet to do so?
 

rwkay

GameMaker Staff
GameMaker Dev.
it is working for me, though i am using the internal version.... I know we had some reported issues but not sure if the fixes made it into the build that went out this week... from what you are saying it likes like that is a no.

Both of your test programs work on the internal, so I think these are fixed just waiting public release

Russell

p.s. output from the internal version of @Alice's program above

1
0
1
1
1
0
1054
string
 

rwkay

GameMaker Staff
GameMaker Dev.
Yes we have overlapping releases as when QA get a build we don't stop fixing bugs so while they are testing (a version that is frozen) we still have the internal build that we (the core team) are fixing bugs on (anything that is critical on the QA build is obviously fixed) when the QA build gets released they get our internal version and then the cycle starts again.

So it can be a bit confusing when we see things reported that we know we have addressed and we have to keep track of which branch a fix went into.

We also tend to do a Feature release then a consolidation/bug fix release while more features are being worked on so you will tend to see that cycle as we go forward (though that is more a rule of thumb than a hard and fast thing)

Russell
 

gnysek

Member
I've checked previous runtime, and seems to work better for now, so I will switch to it until next release.
 
T

trebor777

Guest
Hello,
Seems like I got the bug as well,
I'm in the latest of latest : 2.0.3.56.

I need this to change room simply with their names (hard to know the id)...
(it finds the room i'm in, get the room coordinates from the name, and computes the name of next one to load).

So when is it gonna be fixed?

Since i'm fairly new to GML, here's my code:
Code:
if instance_exists(obj_player) {
    // get current room coordinates in world
    var name = room_get_name(room);
    var coords = string_split(name, "_xy", 1);
    var room_coordinates = string_split(coords[| 1], "_", 2);
    var room_x = real(string_digits(room_coordinates[| 0]))
    var room_y = real(string_digits(room_coordinates[| 1]))
   
    // convert player coordinates to world coordinates.
    var px = (obj_player.x div view_wview[0]) + room_x
    var py = (obj_player.y div view_hview[0]) + room_y
   
    px += sign(obj_player.dx);
   
       
    show_debug_message(px)
    show_debug_message(py)
   
   
    new_room = "rm_test_xy" + string(px) + "_" + string(py)
   
    if variable_global_exists(new_room)  
        room_goto(variable_global_get(new_room));
    else
        show_debug_message("Can't find room: " + new_room)  
}
EDIT:
My bad :p
Rooms are not stored in global variables... Found the asset_get_index(name) method :p
Sorry.
 
Last edited by a moderator:
Top