Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMEdit

A high-end code editor for all things GameMaker · By YellowAfterlife

Autocompletion of struct method arguments and struct properties

A topic by tarnos12 created Aug 08, 2021 Views: 248 Replies: 2
Viewing posts 1 to 3
(3 edits)

Hello,


I have a struct like this one:

function TileObject(_sprite, _object, _blocked,[...]) constructor
{
    sprite = _sprite;
    blocked = _blocked;
    destructible = _destructible;
    movable = _movable;
    rotatable = _rotatable;
    object = _object;
    openable = _openable;    
    Copy = function()
    {
        return new TileObject(sprite, object, blocked,[...]);    
    }
    static Add = function(_sprite, _object, _blocked,[...])
    {
        var _instance = new TileObject(_sprite, _object, _blocked,[...]);
        array_push(global.tileObjects, _instance);    
    }
}

Typing

TileObject.Add(

will not autocomplete arguments

Typing

TileObject. 

will not autocomplete its properties either.


This is the main missing feature of GMS 2 that I complain about, is there a chance this ever gets added?
I don't mind manually "connecting" struct methods to the struct itself, as long as the editor can "see" the connection and make my life easier, so I don't have to keep struct window open on the side to use it.

Perhaps you have some workarounds for it?
JSDocs or a plugin will work for me, just make my life easier :|

Thanks

Developer (1 edit)

GMEdit doesn’t auto-complete arguments in this case because that wouldn’t work in GML - should you do

function TileObject(_sprite, _object, _blocked) constructor
{
    sprite = _sprite;
    blocked = _blocked;
    object = _object;
    Copy = function()
    {
        return new TileObject(sprite, object, blocked);
    }
    static Add = function(_sprite, _object, _blocked)
    {
        var _instance = new TileObject(_sprite, _object, _blocked);
        array_push(global.tileObjects, _instance);    
    }
}
function scr_hello() {
	var o = TileObject.Add(0, 0, 0);
	show_debug_message(o);
}

you would get

Variable <unknown_object>.Add(100013, -2147483648) not set before reading it.
 at gml_Script_scr_hello (line 17) - 	var o = TileObject.Add(0, 0, 0);

because you cannot access static properties through a constructor itself - GML’s static is like C++ static, not like C#’s static.

Should you need to highlight arguments in code that wouldn’t work at runtime, you can use @hint

Thanks, I will try @hint

I will have to read about static again then.