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

SOLVED How to call GML functions from within C/C++?

AceKiron

Member
I managed to create an extension, next step to creating an modding extension is calling specific GML functions from within the extension. But how do I do this? My guess would be that I'd have to pass
GML:
ptr(show_message)
as an argument from GML -> C/C++, but how do I execute the function in C/C++, with the correct arguments?
 

chamaeleon

Member
Not sure why you would expect it to work at all. I certainly would not assume I can call a function in GMS or perhaps more interestingly, a function defined in GML.
 

AceKiron

Member
Not sure why you would expect it to work at all.
Because I know it's possible, look at Apollo, "The extension allows GML code to call Lua functions and for Lua code to call exposed GML scripts / work with exposed GML instances. This means that you can use the extension to implement high-end modding APIs for your game(s)."
It can call exposed GML scripts, which contain functions, so why shouldn't I expect it to be possible?
 

chamaeleon

Member
Why do you think Apollo is calling function pointers raw like you are trying to do (I don't own the extension and don't know what it actually does, what follows is speculation)? There is a lot of nuance to what exposed functions actually means.

Is it possible Apollo users a shared buffer to tell gml to invoke a function or store a variable value? Gml could be busy looping over this buffer looking for the extension to put commands in it, while the extension runs in a separate thread. Having a separate thread for the extension implementation allows the gml side to busy loop until the extension signals through the buffer it has finished its work.
 

AceKiron

Member
Why do you think Apollo is calling function pointers raw like you are trying to do (I don't own the extension and don't know what it actually does, what follows is speculation)? There is a lot of nuance to what exposed functions actually means.

Is it possible Apollo users a shared buffer to tell gml to invoke a function or store a variable value? Gml could be busy looping over this buffer looking for the extension to put commands in it, while the extension runs in a separate thread. Having a separate thread for the extension implementation allows the gml side to busy loop until the extension signals through the buffer it has finished its work.
That would be possible, although I suspect that isn't the case.
 
Top