Skip to content

LUA Hooking System

We could do with a lua hooking system, where we can apply hooks to lua functions in a style to this (similiar to RenPy hooks):

Consider this function in lua somewhere (global scope):

function Add(v1, v2)
  return v1 + v2;
end;

local qh = LuaHooks:CreateHook("Add");

qh:AddPrefix("v1 += 1");

qh:Build();

Where a call to Add(1, 2) would return (v1 + v2) + 1.

Additional restrictions may also be added via file-source path restrictions (useful for a potential replacement for the sw3-exp mod ms-switch change script.