Asset - Extension Override GameMaker's built-in Functions! :D

S

Sam (Deleted User)

Guest
Don't like how a particular function is implemented in GameMaker? Don't worry! You can override existing functions with native extensions! The major key requirement however is using the Extension Maker for older versions of GameMaker or the Extensions node in the IDE and you can NOT use GML scripts, ONLY native code, whether a DLL for Windows, a DYLIB for Mac, an SO for Linux, etc. All you need to do is make a function in your extension that has the exact same function name and set of arguments as as the original implementation. You can also re-implement deprecated or obsolete functions this way, as long as you aren't trying to do that in GameMaker Studio 1.4, because that version will complain about it whenever you try to run or build, and will prevent it.

Works in:
  • GameMaker Studio 1.4 for All Platforms
  • GameMaker Studio 2.x for All Platforms
  • GameMaker 8.1 for Windows
  • GameMaker 7.5 for Mac OS X
 
Last edited by a moderator:
S

Sam (Deleted User)

Guest
YES! @Cloaked Games We can make our own Game_End()!
For example a question message saying "are you sure you want to quit?" If true call the C++ function exit(0); to close the game. The benefit of this is I would assume it would also apply to the close button in the title bar without writing any hooks - not sure though, I haven't tested.

This could potentially be used to write our own graphics systems i.e. Vulkan or Metal by replacing all of the draw functions.

Or even an improved extenal_* family of functions to create extensions using any form of C++ data types as aposed to being limited to pointers and doubles.

Works in both GMStudio 1.4 and GMStudio 2.2 confirmed. In GMStudio 2 you can even bring back obsolete functions this way, as they removed that pesky error for when you are trying to use an obsolete function name.
 
Last edited by a moderator:

Evanski

Raccoon Lord
Forum Staff
Moderator
For example a question message saying "are you sure you want to quit?" If true call the C++ function exit(0); to close the game. The benefit of this is I would assume it would also apply to the close button in the title bar without writing any hooks - not sure though, I haven't tested.

This could potentially be used to write our own graphics systems i.e. Vulkan or Metal by replacing all of the draw functions.

Or even an improved extenal_* family of functions to create extensions using any form of C++ data types as aposed to being limited to pointers and doubles.

Works in both GMStudio 1.4 and GMStudio 2.2 confirmed. In GMStudio 2 you can even bring back obsolete functions this way, as they removed that pesky error for when you are trying to use an obsolete function name.
if im understanding correctly, It may be an error in the IDE syntax handling, if you have a script with the name of a function it gets confused and just runs the script
 
S

Sam (Deleted User)

Guest
if im understanding correctly, It may be an error in the IDE syntax handling, if you have a script with the name of a function it gets confused and just runs the script
Point Is, bug or not, it still works... just not with script resources. You need to use the newer extension system that Studio introduced.
 
L

Lonewolff

Guest
I think I saw a similar thing to this a while back and YYG skirted around the topic and never really gave an answer.
 
S

Sam (Deleted User)

Guest
Hehe, true. :D

If the method is the one I am thinking of, you need the YYC right?
No, actually. Just use the same function name when creating an extension within the IDE (not using scripts)

I initially did it with the VM, I doubt it will be any different using the YYC.
 
L

Lonewolff

Guest
Ooh nice!

Surely that's allowable then. You aren't decompiling, changing headers, or doing anything wrong at all.

I can't see any license or moral dilemma there whatsoever.
 
S

Sam (Deleted User)

Guest
Ooh nice!

Surely that's allowable then. You aren't decompiling, changing headers, or doing anything wrong at all.

I can't see any license or moral dilemma there whatsoever.
Unless of course they consider it a bug and then remove the ability to do that within an update's notice...
 
S

Sam (Deleted User)

Guest
They may now that you have alerted them of the 'bug' :D

I'll be interested to see what they report back to you.
I find it better I tell them and beg them not to change it than to let someone else report it who sees no benefit in it. They need to know this is a desirable thing to have if they are to have any chance in keeping it.
 
L

Lonewolff

Guest
I find it better I tell them and beg them not to change it than to let someone else report it who sees no benefit in it. They need to know this is a desirable thing to have if they are to have any chance in keeping it.
They have enough on their plate chasing bugs and things, as opposed to going out of their way to reduce functionality.
 
H

Homunculus

Guest
Honestly, I don't like this. I see no harm in using a different name for your own implementation instead of overriding the built-in functions (de facto making them inaccessible as long as the extension is there).

Don't get me wrong, I can see some cases where this could be helpful, for example overriding ds_* functions adding a counter could help keeping track of data that has not been cleared properly, but it's too easy to abuse this. In other programming languages this is allowed but you still have a way to reference the original functions, something you don't have here.
 
L

Lonewolff

Guest
I'd be interested in how this could be 'abused'. The extension would have to be present for the new function to work. If you mean from a malicious perspective then anyone can be malicious with GMS, you don't need to override functions to do that.

I see it as a way to either re-implement the existing functions and a way to bring back functions that have been made obsolete that were available in previous versions of GM.
 
S

Sam (Deleted User)

Guest
Honestly, I don't like this. I see no harm in using a different name for your own implementation instead of overriding the built-in functions (de facto making them inaccessible as long as the extension is there).

Don't get me wrong, I can see some cases where this could be helpful, for example overriding ds_* functions adding a counter could help keeping track of data that has not been cleared properly, but it's too easy to abuse this. In other programming languages this is allowed but you still have a way to reference the original functions, something you don't have here.
Not sure what you are getting at. If they don't want to override built in functions, they can just rename them manually in the resource tree.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Current versions of GMS and GMS2 show a warning if you are overriding a built-in function with a script, not sure about extensions.

It's kind of cool, but you have no way to call the original function if you've overriden it with yours, so might as well name yours <function_name>_w (wrapped) and find-replace in project with "whole word" checkbox ticked
 
H

Homunculus

Guest
By abused I mean by marketplace assets or other third party resources, I definitely wouldn't want any of those to override built-in functions (especially if this is not documented properly)
 
Last edited by a moderator:
L

Lonewolff

Guest
By abused I mean by marketplace assets or other third party resources, I definitely wouldn't want any of those to override built-in functions (especially if this is not documented properly)
Ah ok, I understand now.

It comes back to the quality of the asset, there are some bad ones out there. If overriding the functions causes adverse effects, the asset will fall in to the bad apple category and reviews will soon reflect that.
 
S

Sam (Deleted User)

Guest
It comes back to the quality of the asset, there are some bad ones out there. If overriding the functions causes adverse effects, the asset will fall in to the bad apple category and reviews will soon reflect that.
You're forgetting the part that (most, not all) negative reviews you see on any asset by any author is usually by some complaining idiot who doesn't know how to use it because they are new to game maker or the extension doesn't have obscure features they want that were never advertised to be a part of the assets in question to begin with. That's what you call a bad apple reviewer, and it's of no fault to an asset.
 
L

Lonewolff

Guest
Hehe true.

Still had the occasional bad asset out there though. YYG has produced a couple themselves. Like that advert one for Android.
 
S

Sam (Deleted User)

Guest
<post removed>
 
Last edited by a moderator:
Top