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

GML A way to extract all GML (builtin) functions' metadata?

S

syscall

Guest
Hello,

I have been working out on the SDK for Windows DLL extensions... It is going great.
But, I do have a question, is there a function in GML which would return a (big) map data-structure, a value containing all builtin GML functions' metadata (information about the function signature: function name, possible return types, number of arguments and their types)?

(If there is no such "function dump" available via GML (and if no metadata is saved on disk), then I will have to do some web crawling on docs... I don't want to do this.)

If I go offline, I am still able to browse GML function reference pages (F1) in GMS2 (even after restarting IDE), which suggests that metadata is stored on disk. Question is: Where?

(I need this information to save myself a whole lot of time...)

Off-topic question: Is there even function overloading concept in GML? (I guess: not. Please correct me if my guess is wrong.)

Best regards.
 
S

syscall

Guest
eeh.. I could just fire up filemon and see what file is GMS2 loading...

Got it...

Code:
%ProgramFiles%\GameMaker Studio 2\chm2web\YoYoStudioHelp.zip
 

GMWolf

aka fel666
Is there even function overloading concept in GML? (I guess: not. Please correct me if my guess is wrong.)
No not really. But there are variable argument count.
So you could have different scripts for each overload, then have a common script that switches between them based on argument_count.
With a bit of luck the YYC will optimize it out too.
 
S

syscall

Guest
Actually, I see... I could also then use the "typeof" function to check their type.

But there are variable argument count.
In GMS2 extensions, I see you can define a function with "variable length arguments" (varargs):
upload_2019-7-8_17-35-36.png

Since I have answered my own question, now I have a pair of (offtopic) question:
Does this mean you could call your user-defined (script) function with more than 16 arguments?
If so, how do you define such a variadic function in GML script?
 

GMWolf

aka fel666
Does this mean you could call your user-defined (script) function with more than 16 arguments?
I'm not sure. I think 16 is the limit. Or maybe that was changed in a recent update?

If so, how do you define such
You use the argument_count and argument variable like so:
Code:
if (argument_count == 1) {
  var foo = argument [0];
} 
else if (argument_count == 2) {
  var foo = argument[0];
  var bar = argument[1];
}
Note you cannot mix argument[0] and argument0 variables. You have to use one or the other.

AFAIK there is not dump function.
For default variable names I have in the past just written them out by hand.
For functions though I think crawling the CHM might be the way to go.
 

rIKmAN

Member
I'm not sure. I think 16 is the limit. Or maybe that was changed in a recent update?
I vaguely remember reading a thread / post a while back where someone was saying that you can get around the argument limit it by passing in an array as the argument.

My memory is a bit sketchy on it though and I'm not even sure if it was a suggestion or a solution, it just rang a quiet bell in my head.
 

samspade

Member
There's no limit, and I don't think there ever has been, in GMS 2 for arguments in a custom script. The only limit is if you use the built in argument variables of argument0...argument15. The argument[0] is unlimited. As GMWolf noted, you cannot mix argument0/argument[0] forms.
 

rIKmAN

Member
The only limit is if you use the built in argument variables of argument0...argument15.
Maybe that's what the thread I vaguely remember was talking about then.
I tried searching for it but couldn't find anything useful as I can't remember if the thread it was in was even related to that issue.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
A good source of function metadata is the "fnames" file in GMS2 directory. There are a few inconsistencies in it, but you can post-fix those.
 
Top