katsaii / catspeak-lang

A cross-platform modding language for GameMaker games.
https://www.katsaii.com/catspeak-lang/
MIT License
94 stars 6 forks source link

Support built-in functions on `exposeFunctionByName`, `exposeFunctionByPrefix` and `exposeAsset` #123

Closed katsaii closed 4 months ago

katsaii commented 4 months ago

What is your feature request?

Built-in functions should work when passed as a string to exposeFunctionByPrefix and other related functions. E.g. exposeFunctionByPrefix("draw_").

Please describe in detail how you expect this new feature to behave.

Reduce sharp edge.

tabularelf commented 4 months ago

I could PR this directly, I just didn't because it has to be handled in a more jankier way. But the solution for it is just

for(var i = 0; i < 10000; i += 1;) {
    var nativeName = script_get_name(i);
    if (!string_starts_with(nativeName, "<unknown>") &&
        !string_starts_with(nativeName, "@@") &&
        !string_starts_with(nativeName, "$") && 
        !string_starts_with(nativeName, "YoYo") &&
        !string_starts_with(nativeName, "yy")) {
        // Native function exists, check additional for X
    }
}

No existing GML function right now returns native functions in an array. So we need to loop for this information each time.