Closed tabularelf closed 10 months ago
On one additional note, I'm not sure what would be the best approach for detecting a valid function is passed in, while also not including methods for addGMLFunction
. As the others do under CATSPEAK_DEBUG_MODE
. Since is_callable
includes methods, and script_exists
doesn't work for built in functions. I was considering passing in some kind of custom checker function for __catspeak_check_arg
, but I figured I should leave that up for discussion.
Took me a bit to write these up. From previous discussions on Discord, I've came up with these three small but very helpful functions.
env.addGMAsset()
is similar to asenv.addConstant()
but includes extra checks to make sure that it's a valid asset index from a name.env.addGMLFunction()
is similar toenv.addFunction()
, except it adds in a function index as per the name and index. And prevents methods from being added in directly. This does include built in functions, such aslengthdir_x
.env.addGMLFunctionBySubstring()
is similar toenv.addFunction()
, but scans all user function indexes for each substring that is passed (starting from 100001, meaning that built-in functions are ignored) and adds anything that matches the substring with the first part of the name. So"scribble"
would add"scribble"
,"scribble_*
but not"__scribble"
or"scr_scribble"
.The name for
addGMLFunctionBySubstring
I'm not really settled on entirely, but I am open to suggestions on what could be better named. (alynne suggestedPartialName
in place ofSubstring
).All of these do include test cases. And for
.addGMLFunctionBySubstring()
, I've includedscr_testing_example_functions
for the demonstration of what it does/doesn't add in.