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.
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.
Flix's Beginners Macro Guide is also a great starting point to learn the basics.
Some examples of using script macros are below.
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.
await character.rollSkill({ skill: "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.
await actor.rollSkill({ skill: "ath" });
List of skill abbreviations:
"acr" => Acrobatics
"ani" => Animal Handling
"arc" => Arcana
"ath" => Athletics
"dec" => Deception
"his" => History
"ins" => Insight
"itm" => Intimidation
"inv" => Investigation
"med" => Medicine
"nat" => Nature
"prc" => Perception
"prf" => Performance
"per" => Persuasion
"rel" => Religion
"slt" => Sleight of Hand
"ste" => Stealth
"sur" => Survival
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({ ability: "str" });
// or this for a player that is controlling multiple
// tokens.
actor.rollAbility({ ability: "str" });
// This would skip the dialog and roll an ability test
await character.rollAbilityCheck({ ability: "str" });
// And this would skip the dialog and roll an ability save
await character.rollSavingThrow({ ability: "str" });
List of ability abbreviations:
"str" => Strength
"dex" => Dexterity
"con" => Constitution
"int" => Intelligence
"wis" => Wisdom
"cha" => Charisma
This is a direct way to play audio.
AudioHelper.play({src: "audio/SFX/Fire arrow.mp3", volume: 0.8, autoplay: true, loop: false}, true);