OFFICIAL GMS 2.3.0 BETA ANNOUNCEMENT

A few questions on efficiency and optimization.

1.) How fast is variable and function access for structs in comparison to other storage methods and traditional objects?

2.) Do structs become slower to read/write as they grow in size and/or inherit members?

3.) Do instances of structs contain a separate reference for every static variable or method? Or is a reference shared by all instances of the struct type?

If these are duplicates of answered ones I can delete if directed to the responses.
 
Last edited:

gnysek

Member
3.) Do instances of structs contain a separate reference for every static variable or method? Or is a reference shared by all instances of the struct type?
They share reference as long, as you don't create a local variable with same name in struct (only from outside of struct, using x.value = y), which will then override static in this one specific instance. You can change value of static only from inside of structs. I already reported it as bug, but Russell says it's by design 🤔 Manual is updated now and mention this.
 

DanTheCan

Member
Just figured out that you can override what a struct prints when calling show_debug_message() by including a toString method.

GML:
struct = {
    a : 0,
    b : 1,
    toString : function()
    {
        return "overridden";
    }
}

show_debug_message(struct)
It will print:
GML:
overridden
Instead of:
GML:
{ a : 0, b : 1 }
 

DanTheCan

Member
Also, is there a way inside of a struct to get itself? The keyword 'self' refers to the object instance that created the struct, so it's not what I need.
 

Cpaz

Member
Just figured out that you can override what a struct prints when calling show_debug_message() by including a toString method.

GML:
struct = {
    a : 0,
    b : 1,
    toString : function()
    {
        return "overridden";
    }
}

show_debug_message(struct)
It will print:
GML:
overridden
Instead of:
GML:
{ a : 0, b : 1 }
This is weird, because it's not really in line with the rest of the naming conventions that GM uses. I mean, I LOVE that this is a thing, but very strange. I wanna test this when I get the chance.
 
Also, is there a way inside of a struct to get itself? The keyword 'self' refers to the object instance that created the struct, so it's not what I need.
GML:
function MyStruct(a) constructor
{
    self.a = a;

    static AddNumber = function(b) {
        a += b;
        return self;
    }
}

var _struct = new MyStruct(10);

// Even though you are returning self, this won't work!!
_struct .AddNumber(10).AddNumber(10)

// You will need to wrap the calls in parenthesis in order for them to work ;)
(_struct .AddNumber(10)).AddNumber(10) // as you are returning self you can chain calls


show_debug_message(_struct .a); // 30

// as you can see you can already return the reference to the struct itself using "self"
 
Last edited:

kburkhart84

Firehammer Games
GML:
function MyStruct(a) constructor
{
    self.a = a;

    static AddNumber = function(b) {
        a += b;
        return self;
    }
}

var _struct = new MyStruct(10);
_struct .AddNumber(10).AddNumber(10) // as you are returning self you can chain calls
show_debug_message(_struct .a); // 30

// as you can see you can already return the reference to the struct itself using "self"
I've seen that "trick" elsewhere, it hadn't occurred to me to do it with gml just yet, but it makes perfect sense.
 

DanTheCan

Member
This is weird, because it's not really in line with the rest of the naming conventions that GM uses. I mean, I LOVE that this is a thing, but very strange. I wanna test this when I get the chance.
Another cool thing this means is that if you have structs inside structs that have a toString method, it uses that toString method within the usual struct printout. So:
GML:
struct = {
    a : 0,
    b : 2,
    toString : function() {
        return “a is “+string(a)+” b is “+string(b)+” “;
    }
}

struct2 = {
    c : 18,
    s : struct
}

show_debug_message(struct2);
This will print:
GML:
{ c : 18, a is 0 b is 2 }
 

saffeine

Member
GML:
function MyStruct(a) constructor
{
    self.a = a;

    static AddNumber = function(b) {
        a += b;
        return self;
    }
}

var _struct = new MyStruct(10);
_struct .AddNumber(10).AddNumber(10) // as you are returning self you can chain calls
show_debug_message(_struct .a); // 30

// as you can see you can already return the reference to the struct itself using "self"
do self-referenced chained methods actually work now, or is it something they're still working on?
i hate to ask here of all places but i knew it was something they were looking into and this reply came across like something recently successful.
the last update to the beta forums / ide was yesterday and it does say something about chained methods but after testing it just now, nothing seems any different despite being on the most recent version :(

i'm not sure if i'm just missing something in updating or if it's something they haven't finalised just yet.
 

DanTheCan

Member
do self-referenced chained methods actually work now, or is it something they're still working on?
i hate to ask here of all places but i knew it was something they were looking into and this reply came across like something recently successful.
the last update to the beta forums / ide was yesterday and it does say something about chained methods but after testing it just now, nothing seems any different despite being on the most recent version :(

i'm not sure if i'm just missing something in updating or if it's something they haven't finalised just yet.
I just tested this code, and it doesn't work for me either.
 

Cpaz

Member
Just figured out that you can override what a struct prints when calling show_debug_message() by including a toString method.

GML:
struct = {
    a : 0,
    b : 1,
    toString : function()
    {
        return "overridden";
    }
}

show_debug_message(struct)
It will print:
GML:
overridden
Instead of:
GML:
{ a : 0, b : 1 }
Can confirm, this works.
Holy crap that's great.
 

Crescent

Member
In a recent project I tried doing chained method dereferencing as well:

GML:
deck
    .search(
      function (_card) {
         if (_card.manaCost <= 1) {
              return true;
         }
         return false;
       }
     );
    // Search function returns a CardList struct with the select() method 
    .select(player.id);
Doesn't work, but it would be nice to have js style multiline method accessors.
 
do self-referenced chained methods actually work now, or is it something they're still working on?
i hate to ask here of all places but i knew it was something they were looking into and this reply came across like something recently successful.
the last update to the beta forums / ide was yesterday and it does say something about chained methods but after testing it just now, nothing seems any different despite being on the most recent version :(

i'm not sure if i'm just missing something in updating or if it's something they haven't finalised just yet.
The code I posted can actually be made to work:
It is possible to do it in GML right now but you need a strange work around, though.
This has been reported and is being addressed :D

For the time being (to test things) you can do what I did below :D

GML:
function MyStruct(a) constructor
{
    self.a = a;

    static AddNumber = function(b) {
        a += b;
        return self;
    }
}

var _struct = new MyStruct(10);
// take a look at the parenthesis around each chain ;)
((_struct.AddNumber(10)).AddNumber(10)).AddNumber(10)
show_debug_message(_struct.a); // 40
 
Last edited:

saffeine

Member
You can define accessors for structs?
not quite. if you look again you'll see that the struct contains another variable called 'array' that you use the accessor on.
unless i missed something, this isn't so much a new data structure so much as it is a handy constructor for manipulation.
MusNik implemented a few methods that turn array handling into quick work.
 
You can define accessors for structs?
you cannot (I also was curious when I saw the post because I was sure that was not possible)
but if you have an array insde a struct

This code is just for the purpose of example and shouldn't be used as is :D
GML:
function MyList() constructor
{
    data = [];
    static Add(value)
    {
        data[@ array_length(data)] = value;
    }
}

var myList = new MyList();
myList.Add(10);
myList.Add(20);
myList.Add(30);

// in some kind of way you are using an accessor! (that's what the OP was talking about)
myList.data[2] // 30
 
Last edited:

DirectOrder

Member
Can anybody point me to any info on using tags in GML? That's one of the only pieces I can't find info on yet. For instance, in Unity you can do variable = GameObject.FindGameObjectsWithTag("Enemies");
but I don't know the syntax or any of the built-in functions here. Any help would be appreciated!
 

vidboy

Member
anyone else experience the issue of persistent objects breaking after room change if you define its functions in its create event?
1591188287276.png
EDIT: This has been fixed in the latest update. Whew.
 
Last edited:

kyuzi

Member
Is anyone still able to enter the beta? I can't seem to get the option to show up even though I am logged in on the support page.
 

TsukaYuriko

🌠
Forum Staff
Moderator
Applications have been closed according to an update by @rmanthorp published on the r/gamemaker Discord:
rmanthorp said:
I will say we've closed applications for the beta now as we look to soon move to the next phase of a fully open beta
There hasn't been an official announcement on any of the official venues (that I am aware of) about this yet.
 

rmanthorp

YoYo Games Staff
Admin
YYG Staff

Nocturne

Friendly Tyrant
Forum Staff
Admin
Can anybody point me to any info on using tags in GML? That's one of the only pieces I can't find info on yet. For instance, in Unity you can do variable = GameObject.FindGameObjectsWithTag("Enemies");
but I don't know the syntax or any of the built-in functions here. Any help would be appreciated!
Have you checked the manual? It's all explained there in the section GML Reference > Managing Resources > Assets and Tags.
 
Nice, most recent update fixed objects being invisible in the room editor when their animation speed is 0.

I used to toss up switching to Godot, were in not for gms2's console exports. But this update, for me personally makes GMS2 miles ahead of any other 2d engine.
Method variables and structs have made everything so concise and pretty now.
 

gnysek

Member
So is there any thoughts about the release date of 2.3.0 ?
Date of public beta + another 2-3 weeks at least (if there won't be critical bugs, but I think that most interested already gave it enough stress test, so most of bug reports might be non-bugs in fact, but wrong understanding of how things works).

I also hope the roadmap will finally get updated, as we should be at 2.3.1 today. https://help.yoyogames.com/hc/en-us/articles/231719448-RoadMap .
 

Zhanghua

Member
Wake up, then open the forum to see anything new, finally nothing happening.
 
Last edited by a moderator:

samidare

Member
Icons on a Mac with retina display are still very blurry (just like in the previous versions).
It seems to be the case with all icons except for the ones in the new Asset Browser.

It would also be nice if the empty space above the icon row could be removed (yellow markup).

Screenshot 2020-06-06 at 12.16.38.png
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
You should report these things in the Beta forums (link in the first post of this topic).
 

gnysek

Member
Hey, our website logins on accounts are currently disabled as we run a maintenance update. We expected this update to take a few hours. GameMaker IDE logins are not impacted during this time. Thank you!
That may mean they are adding a 23.x versions to "allowed" list on all accounts, which means public beta (all GMS2 licenses are for 2.x versions, if there's a version with different release number, then a separate license need to be enabled per each allowed account, 23.x is one of them). Notice, that latest open beta got no more info about NDA and other stuff in release notes, and is more neutral.
Of course I may be wrong.
 

Zhanghua

Member
The web update is not related to 2.3 in any way. However, fully open 2.3 beta is coming real soon. We then expect it to be in open beta for a few weeks before the full launch. This is all depending on open beta feedback.
Any official message of beta makes me a climax now.
 

Zeo666

Member
If I've missed this new feature forgive me but I'd love to be able to import and export scripts on bulk. I'd also love to be able to import a project into another project. That way I can create different systems (input, rendering, audio etc) in their own projects and combine multiple for my new game projects. It would save the hassle of publishing projects to the marketplace just so I can import them into my projects.
 

kburkhart84

Firehammer Games
If I've missed this new feature forgive me but I'd love to be able to import and export scripts on bulk. I'd also love to be able to import a project into another project. That way I can create different systems (input, rendering, audio etc) in their own projects and combine multiple for my new game projects. It would save the hassle of publishing projects to the marketplace just so I can import them into my projects.
The current version lets you export local asset packages. It doesn't have to be for the marketplace. This is how people are selling them on other marketplaces like itch, and a good way to go to build a new project from previous "code bases."
 

Hyomoto

Member
@Joh - This is a tricky subject. Unlike everything else, data structures aren't cleaned up automatically by the garbage collector, and there's no way to get a struct to clean up the internal list/stack/etc... except by doing something like: list.destroy() which may not actually have the expected effect. That is to say, the struct could continue to exist if a reference exists even though you cleaned up the internal structure. All of those considerations aside, it can be helpful to do this, especially if you want some kind of extra information bound to the list. In a more significant example, I wrote a `ds_table` structure that combines a map and list together so that it's possible to look things up by index or key.



As for what I actually came to post for, one of my suggestions snuck it's way into 2.3! I hadn't noticed, but not only did we get `string_pos_ext` as I'd hoped, we also get `string_pos_last` and `string_pos_last_ext` so a huge thank you to those hard workers behind the scenes!
 
Top