VTT Hook Macros
Advanced Scripting Module
This module allows you to set macros to run when a particular Hook is sent by Foundry VTT.
Installation
To install, import this Manifest into your module browser.
How to use
- Open either
SettingsorLocal settingsin the module's configurationSettingswill run for every user and can only be configured by a GMLocal settingsare saved as local settings, will only run for the respective user, and can be used by any user
- Enter data:
Hook name(required): The name of the hook to run the macro for. You can runCONFIG.debug.hooks = truein the Developer Console of your browser to learn about which hooks get triggered by certain interactionsMacro ID(required): The UUID of the macro to run. You can find a macro's UUID by opening the macro editor and clicking on the passport icon in the window's title bar. A message stating "Macro UUID ... copied to clipboard." should pop up.Macro args(optional): Specify any arguments the macro might consume. The pattern iskey1=value1, key2=value2, .... Any surrounding spaces will be stripped, sokey1 = value1is the same askey1=value1.
- Press the
+button andSave
You can then access the arguments in the macro using the arguments parameter:
arguments[4]contains the specified arguments as key-value pairs, as well as the hook's arguments ashookArgumentsarguments[5]througharguments[n]contain the argument values without their keys
Example: Configured argument list is name=John,number=12 and the hook has the arguments [{name: "Hero"}, {action: "create"}, "uABwxqaeHZHpuK6l"]
arguments[4]contains{name: "John", number: "12", hookArguments: [{name: "Hero"}, {action: "create"}, "uABwxqaeHZHpuK6l"]}arguments[5]contains"John"arguments[6]contains"12"arguments[7]contains[{name: "Hero"}, {action: "create"}, "uABwxqaeHZHpuK6l"]
Things to watch out for
Don't create macros that run from the chat hook and create chat messages that take more than 1 seconds to output to chat.
Known non-functional hooks
- init
Changelog
Check the Changelog
If you acidentally created a macro that locks you out of the game. You can fix it by holding the END key while logging into your world. This makes the module not run any macros.