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

Struct functions, delta_time, and YYC

I wanted to post about some issues I've run into in case someone else has the same problem. As of now, if you're output is YCC, it looks like you can't reference delta_time inside a function defined in a struct. This code inside a create event runs just fine in VM and HTML, but fails for YCC:

GML:
test = {
    data: 0,
    set_data: function() {
        data = delta_time;
    }
};

test.set_data();
show_debug_message(test.data);
The error I get for this specific example is:

___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object o_test:

STRING argument is unset############################################################################################
gml_Object_o_test_Create_0 (line 9)
However it's varied in different contexts. All of them seem to have something to do with the variable being unset. Luckily, it looks like we can get around this by setting delta_time to another variable outside of the struct definition, and referencing that instead. This code works just fine on my machine when outputting to YCC:

GML:
global.DELTA_TIME = delta_time;

test = {
    data: 0,
    set_data: function() {
        data = global.DELTA_TIME;
    }
};

test.set_data();
show_debug_message(test.data);
I'm curious to know if anyone else is running into similar problems.
 

Sergio

Member
I don't know why the second option works, but, to avoid problems with show_debug_message you should transform the data you want to print into a string

GML:
show_debug_message(string(test.data));
 
I wanted to post about some issues I've run into in case someone else has the same problem. As of now, if you're output is YCC, it looks like you can't reference delta_time inside a function defined in a struct. This code inside a create event runs just fine in VM and HTML, but fails for YCC:

GML:
test = {
data: 0,
set_data: function() {
data = delta_time;
}
};

test.set_data();
show_debug_message(test.data);
Did you check the value of data inside the debugger, rather than only using show_debug_message? I haven't updated yet (in the middle of a project) so I can't check but it's a far less onerous bug if it's simply the show_debug_message failing to string the test.data output instead of data not actually being able to be set to delta_time inside of the struct.

EDIT: Lol, I just realised you can't access the debugger properly in YYC. So I'm curious what happens if you just try to read the data later in the YYC, rather then show_debug_message()'ing it, does it still throw the error?
 
Last edited:
Top