-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
constructor_call
#99
Comments
constructor_call(constructor, args, [length], [offset])
constructor_call
Made |
This is nothing more than just replacing |
Oh my apologies, when viewing your initial post I must have missed the gist link on the bottom. It did not occur to me there was already a suggestion. Though I do believe sticking to the standards of gml syntax |
constructor_call should be seen as a counterpart to method_call, which is also array based. This contrasts with script_execute and script_execute_ext, but script_execute itself comes from pre-modern GML when we couldn't do "function_variable(arg1, arg2, arg3)" syntax. So yeah, I'd rather go for a single array-based constructor_call here. |
I figured I should add to that, and on top.
|
In the event they make use of string acceptance, similar to the asset or string argument input for Though the argument for Also I had no idea statics were carried into an arbitrary struct when executing a constructor function on it. possibly a unintended feature or bug? the syntax doesnt appear to imply that it will write any statics to the object, raises even further questions as to what happens to an object executing a constructor. But when building out a ECS or any system which inherits from more then one parent the static binding would be a good option. (if possible that is) |
It's a feature, the whole intent is to treat it exactly as if we had called
I don't think YoYoGames wants to start adding a string -> ref interpreter into various of functions, let alone |
Note: I have wanted to submit a function like this for a long while into the community toolbox, but I wanted to wait until things were relatively stable. As of 2024.11,
script_execute_ext
is now being supported to allow treating the current scope as an instance of a constructor function! See YoYoGames/GameMaker-Bugs#7995 for more info.What does it do?
constructor_call(constructor, args, [length], [offset])
at its simpliest form, mimics the behaviour ofscript_execute_ext
, but rather than treating it like a normal function, it runs as if you were to donew Construct(arg, ...)
. This allows you to create essentially a constructor instance with as many arguments as needed.Useful for scenarios such as:
constructor_call
implementation.Can you give us an example of how it can be used?
Why should the community toolbox have this?
This has been a long requested feature, dating back to late July of last year. Specifically YoYoGames/GameMaker-Bugs#3055. As this has it's multiple use cases, I feel that it warrents some benefits in being apart of the community toolbox.
What does the function code look like?
I have written a gist awhile ago when I had confirmation that the changes for 2024.11 will be included (and after some bug reports for VM/YYC)
https://gist.github.com/tabularelf/d686a940f46c7c45daa2dd78b0358d30
The text was updated successfully, but these errors were encountered: