gmCallback
HTML5 JavaScript Callbacks
By JacksonYarr

About

gmCallback is an extension for GameMaker HTML5 that allows for external JavaScript calls to GameMaker scripts. gmCallback does not require constant polling, and remains functional regardless of game obfuscation.


Functions

callback_script(name,args);

This function needs to be called at the beginning of GameMaker scripts that will be executed by external JavaScript calls.

name specifies an external JavaScript function name which can be used to execute the GameMaker script.

args specifies the number of arguments the GameMaker script takes.

Returns true or false.

Warning: The GameMaker script should immediately exit if the function returns false.

Warning: Remember to ensure that args is always correctly set to the number of arguments the GameMaker script takes.

Note: name should not include parentheses().

callback_define_script(name,script);

Initialises the specified GameMaker script for JavaScript callbacks.

name specifies the external JavaScript function name which can be used to execute the GameMaker script.

script specifies the GameMaker script.

Returns true if the function has been successfully initialised for external JavaScript calls, otherwise false.

Note: name should be the same name specified in the GameMaker script by the function callback_script().

Note: The 'script' argument requires parentheses() after the specified GameMaker script. The 'name' argument should not include parentheses().

Warning: This function should only be called once per script. Any additional calls will result in the specified script executing.


JavaScript Functions

gmCallback.name(args);

This function can be called within external JavaScript to execute the GameMaker script linked to the specified name.

Warning: Remember to ensure the correct number of arguments are always supplied.


License

gmCallback is licensed under a Creative Commons Attribution 3.0 Unported License.

http://creativecommons.org/licenses/by/3.0/