Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Setting "Script_Activate" for Menu Tutorial

A topic by Dougie created Aug 27, 2024 Views: 64 Replies: 2
Viewing posts 1 to 3

When generating a menu using your tutorial, where do I place the "Script_Activate". I can't in the room editor, since these buttons are generated in the Creation Code event.

I tried using temporary vars for each element and setting it manually using "_button.Script_Active = Script" to no luck.

Any suggustions?

Developer (4 edits) (+1)

Hi, sorry for the delayed answer, i'm just back from vacations.


First of all, create a script file that will hold your callback functions, then, create the callback function itself, inside of it.

(Basically, the script files are treated like containers for callback functions, you don't call the file itself, but the functions inside of it).


For example:

function MyCallbackFunction() {

  /// That's the body of your function

}

Then, when you add elements to your menu, just pass the name of the function, since it's inside a script, you can call it from anywhere, the name will be orange (a way to make sure you type it right).

Example:

var _main = Add_Group("Main Menu");

        _main.Add_element(GGL_sub_button,    "DoSomething", MyCallbackFunction, _dx,      0, _w, _h);

Thank you!