A macro is a set of commands (such as a roll, a message, or a Javascript scriptlet) that Foundry can execute when the associated macro button is pressed.
Macros were added in Foundry VTT version 0.4.4
A community-contributed repository of Macros can be found here: github.
Chat macros are chat commands that have been saved for later reuse. See section on Chat commands
Script Macros in Foundry use the underlying JavaScript API to execute various commands. The API respects the permissions of the user executing the macro, so players cannot delete your big bad evil guy for example.
See also: Learning API, and API Snippets (many of them can be used in a Macros)
Some examples of using script macros follows.
await game.tables.getName('Table Name').draw();
Replace the Table Name
with the one you want to use.
Here are a few simple scripts useful for rolling skill checks using the dnd5e system.
// This would roll an athletics skill check for the players character.
// Just replace 'ath' with the appropriate skill abbreviation for the
// skill you'd like to roll.
character.rollSkill('ath');
// This would be used if a player controls more than one character.
// It would roll the check for which ever token the player has selected.
actor.rollSkill('ath');
List of skill abbreviations:
These are examples for rolling an attribute check.
// This would pop up a dialog asking if you'd like
// to roll a Strength Test or a Strength Save.
// Just replace "str" with the appropriate ability
// abbreviation.
character.rollAbility("str");
// or this for a player that is controlling multiple
// tokens.
actor.rollAbility("str");
// This would skip the dialog and roll an ability test
character.rollAbilityTest("str");
// And this would skip the dialog and roll an ability save
character.rollAbilitySave("str");
List of ability abbreviations:
This is a direct way to play audio.
AudioHelper.play({src: "audio/SFX/Fire arrow.mp3", volume: 0.8, autoplay: true, loop: false}, true);