Skip to content
This repository was archived by the owner on Jul 30, 2023. It is now read-only.

'HookFunction' function (EN)

Archie edited this page May 23, 2021 · 2 revisions

HookFunction function

Runs your function before / after the game attempts to execute a script / object event.

Syntax

<void> HookFunction(
    <string / LCT> GameScript,
    <string> LuaFunctionName,
    <boolean> RunBeforeScript
);

Parameters

GameScript

Type: String / LCT

The name of the script. Examples: gml_Object_obj_battlecontroller_Create_0, gml_Object_obj_mainchara_Create_0.

You may also used one of the predefined types:

  • LCT.Script - Runs on every script execution
  • LCT.Frame - Runs every frame (30FPS usually)
  • LCT.DrawEvent - Runs every DrawEvent (object events ending in Draw_0).

LuaFunctionName

Type: String

The name of the function that should be called when the conditions are met. Examples: FixEchoFlower, ShowRoomName

The target Lua function can accept an argument, in which case it will get filled by the name of the calling script (useful with LCT hooks).

RunBeforeScript

Type: Boolean

true if you want the function to run before the script, false if you want the function to run after the script.

Return Value

Type: void

Example

function ShowRoomName()
    -- Draw Stuff here
end

HookFunction("gml_Object_obj_time_Draw_64", "ShowRoomName", false); -- Run the "ShowRoomName" function after "gml_Object_obj_time_Draw_64" executes.

Clone this wiki locally