Blog post: (link)
To explain it simple, think of it as execute_string variant. Except in other language. And at times more powerful than GML.
Installation: Include extension in project.
dj_init - resets all currently loaded functions in extension.
dj_add(name, code) - adds a new function to index.
Index can be both number or string.
Code can be also created dynamically (same as you would do with execute_string)
dj_call(name) - calls loaded function, returning it's value.
dj_addN(index, ..., code) - similar to dj_add, but allows to specify names of parameters.
With those, you will be able to access them by given names in function.
dj_callN(index, ...) - to be used in pair with above, calls function, providing it given parameters.
dj_exists(index) - returns if a function is bound to given index.
dj_count() - returns total number of functions loaded at the moment.
dj_run(code) - creates and executes piece of code without storing it anywhere. Is intended to be used with functions that are used only once through the game or are not worth storing.
Add line of text to GameMaker debug console:
dj_add3('color', 'r', 'g', 'b', "document.body.style.backgroundColor = 'rgba('+r+ ','+g+ ','+b+ ',1)';"); dj_call3('color', 64, 64, 64);Create function from concatenated strings:
index = 'some' dj_add('get_' + index, "return '" + index + "';") show_message(dj_call('get_some'))
* It is quite easy to crash your game with this extension, since errors are not handled anyhow by default.
I've actually removed that because it was hard to determine why something was not working with errors being ignored silently.
* Other loaded functions can be accessed as 'dj_data[index](...)'.
* It is recommended that you do not include line breaks in loaded code (either wrap lines by "'+(next line)+'", or string_replace_all them) - mis-matches in string format between loaded string and game itself may cause errors.
* While this allows 'dynamic' code, there is no defined way to access in-game resources without embedding them into functions or passing them as arguments.