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

GameMaker Cannot use function name with extension

CloseRange

Member
In my quest to create an extension I have seem to run into a small problem:
Script: RPGX_FrameInit at line 24 : cannot use function/script name for a variable, using "RPGX_FrameCustom_Text_Step"
The way the code is set up I have scripts that can be passed through arguments and then set in some variables.
This works fine but when I export the extension and try to run the code on another project I get this error. Is it not possible to pass extension scripts as variables or do I need to do something special first?
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
There are two common ways to use scripts in extensions:
  • Add a "placeholder GML" file to the extension, open it externally, add the scripts in there (separated by "#define <name of script following>")
  • Add script assets to the extension when you pack it up
It sounds like you are currently doing a bit of both, or are doing something else unusually - I'd suggest to show a snip of GML code that raises the error
 

CloseRange

Member
@YellowAfterlife I created a bunch of scripts in game maker 2 and then copied and pasted the code into a .gml file and seperated them with the #define
The extension itself doesn't use any scripts but there is this code (where the problem is occuring)
Code:
var o = RPG_FrameCreate("UI_base", noone, noone);
    o.IS_BASE = true;
    RPG_FrameHook(o, HOOK_draw, RPGX_FrameGlobalDraw);
    RPG_FrameHook(o, HOOK_step, RPGX_FrameGlobalStep);
    RPG_FrameHook(o, HOOK_create, RPGX_FrameCustom_Base_Create);
var oi = RPG_FrameCreate("UI_interactable", UI_base);
    RPG_FrameHook(oi, HOOK_step, RPGX_FrameCustom_Button_Step);
    RPG_FrameHook(oi, HOOK_create, RPGX_FrameCustom_Button_Create);
    RPG_FrameActive(oi, false);
var m = RPG_FrameCreate("UI_mouse", UI_base);
    RPG_FrameHook(m, HOOK_step, RPGX_FrameCustom_Mouse_Step);
    RPG_FrameHook(m, HOOK_create, RPGX_FrameCustom_Mouse_Create);
    RPG_FrameSize(m, 1, 1);
var t = RPG_FrameCreate("UI_text", UI_base);
    RPG_FrameHook(t, HOOK_create, RPGX_FrameCustom_Text_Create);
    RPG_FrameHook(t, HOOK_step, RPGX_FrameCustom_Text_Step);
    RPG_FrameHook(t, HOOK_draw, RPGX_FrameCustom_Text_Draw);
var g = RPG_FrameCreate("UI_grid", UI_base);
    RPG_FrameHook(g, HOOK_create, RPGX_FrameCustom_Grid_Create);
RPGX_FrameGlobalDraw and everywhere where it says RPGX_ is a custom script that is also part of the extension.
They are also inside the gml file but perhaps the order could be an issue? I havn't tried it yet but the order that the scripts are in the gml file are just alphabetical.

Though I can call the scripts just fine from within other scripts it's just passing them as variables or storing them as ones.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Unusual, I don't think I've ran into that before. You could workaround this by using asset_get_index to resolve the script ID from the name; I'd suggest to also file a bug report with your sample project attached.
 
Top