### Math example with space Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements Example demonstrating the importance of spaces for math operations with actor data. ```json "value": "max(1,@actor.level -2)" ``` -------------------------------- ### Compact match function example Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements A more compact version of the match function example, demonstrating simplified logic. ```js match( when(lte(@actor.level, 6), 1), when(lte(@actor.level, 16), 2), 3 ) ``` -------------------------------- ### Token Image - Scaled Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements Example of changing the token image and its scale. ```json { "key": "TokenImage", "value": "images/tokens/big-wings.webp", "scale": 2.5 } ``` -------------------------------- ### SubstituteRoll for Assurance Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements Example of setting a fixed roll value for Assurance. ```json { "key": "SubstituteRoll", "label": "PF2E.SpecificRule.SubstituteRoll.Assurance", "selector": "{item|flags.system.rulesSelections.assurance}", "slug": "assurance", "value": 10 } ``` -------------------------------- ### Event-driven Temp HP Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements Example of applying Temporary HP on specific events like creation or turn start. ```json { "events": { "onCreate": true, "onTurnStart": true }, "key": "TempHP", "predicate": [ "feature:inexorable-iron", "self:weapon:melee", "self:weapon:hands-held:2" ], "value": "max(floor(@actor.level / 2), 1)" } ``` -------------------------------- ### Match function with when and btwn Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements Example of using match, when, and btwn functions for complex scaling logic. ```json { "key": "Weakness", "type": "fire", "value": "match(when(lte(@actor.level, 6), 1), when(btwn(@actor.level, 7, 16), 2), when(gte(@actor.level, 17), 3))" } ``` -------------------------------- ### Item Modifier Example Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements An example of an item modifier for the 'acrobatics' selector. ```json { "key": "FlatModifier", "selector": "acrobatics", "type": "item", "value": 1 } ``` -------------------------------- ### FlatModifier Example Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements An example of a FlatModifier that adds 1 to strike damage. ```json { "key": "FlatModifier", "selector": "strike-damage", "value": 1, "slug": "some-modifier" } ``` -------------------------------- ### Circumstance Modifier Example Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements An example of a circumstance modifier for 'acrobatics' with a predicate for a specific action. ```json { "key": "FlatModifier", "selector": "acrobatics", "type": "circumstance", "value": 2, "predicate": ["action:tumble-through"] } ``` -------------------------------- ### Token Image - Transition Animation Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements Example of specifying a transition animation for token image changes. ```json { "key": "TokenImage", "value": "images/wolf.webp", "scale": 2, "animation": { "transition": "hologram" } } ``` -------------------------------- ### Ternary operator example Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements Example of using a ternary operator for conditional scaling of a modifier. ```json { "key": "FlatModifier", "selector": "ac", "value": "ternary(gte(@item.level, 3), 2, 1)" } ``` -------------------------------- ### TokenLight Example 2 Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements An advanced configuration for TokenLight, including luminosity, gradual light, contrast, saturation, coloration, angle, and alpha. ```json { "key": "TokenLight", "value": { "animation": { "intensity": 1, "speed": 1, "type": "lightdome" }, "bright": 30, "color": "#9b7337", "dim": 0, "shadows": 0, "luminosity": 0.5, "gradual": false, "contrast": 0.5, "saturation": 0, "coloration": 1, "angle": 360, "alpha": 0.1 } } ``` -------------------------------- ### TokenLight Example 1 Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements A basic configuration for the TokenLight rule element, demonstrating animation, bright light, color, dim light, and shadows. ```json { "key": "TokenLight", "value": { "animation": { "intensity": 4, "speed": 1, "type": "torch" }, "bright": 20, "color": "#9b7337", "dim": 40, "shadows": 0.2 } } ``` -------------------------------- ### Match function formatted for readability Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements The same match function example, formatted for easier understanding of its structure. ```js match( when(lte(@actor.level, 6), 1), when(btwn(@actor.level, 7, 16), 2), when(gte(@actor.level, 17), 3) ) ``` -------------------------------- ### Basic Strike Example Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements A fundamental example of a 'Strike' rule element, demonstrating basic damage properties. ```json { "key": "Strike", "category": "unarmed", "damage": { "base": { "damageType": "slashing", "dice": 1, "die": "d8" } }, "group": "brawling", "label": "Tiger Claw", "traits": [ "agile", "finesse", "unarmed", "nonlethal" ] } ``` -------------------------------- ### EphemeralEffect Example 3: With Alterations Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements This example demonstrates applying an alteration to an EphemeralEffect, such as overriding a badge value. ```json { "key": "EphemeralEffect", "affects": "origin", "selectors": [ "strike-attack-roll" ], "uuid": "Compendium.pf2e.conditionitems.Item.MIRkyAjyBeXivMa7", "alterations": [{ "mode": "override", "property": "badge-value", "value": 2 }] } ``` -------------------------------- ### Inline Action Examples Source: https://github.com/foundryvtt/pf2e/wiki/Style-Guide Demonstrates how to use system action macros inline, including specifying variants and DCs. ```text [[/act grapple]] ``` ```text [[/act administer-first-aid variant=stop-bleeding]] ``` ```text [[/act sneak dc=20]] ``` ```text [[/act seek dc=thievery]] ``` ```text [[/act make-an-impression statistic=performance]] ``` -------------------------------- ### Nested ternary operators example Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements Example of using nested ternary operators for more complex conditional scaling. ```json { "key": "FlatModifier", "selector": "ac", "value": "ternary(gte(@item.level, 7), 3, ternary(gte(@item.level, 3), 2, 1))" } ``` -------------------------------- ### Options Example Source: https://github.com/foundryvtt/pf2e/wiki/Style-Guide Example of using the options parameter for roll options. ```Wiki @Check[reflex|dc:25|options:damaging-effect] ``` -------------------------------- ### Max function example Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements Example of using the max function to ensure a minimum value for a scaled modifier. ```json "value": "max(1,floor(@actor.level/2))" ``` -------------------------------- ### Basic RollOption Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements A basic example of a RollOption setting a new roll option. ```json { "key": "RollOption", "domain": "all", "option": "afraid-of-dragons" } ``` -------------------------------- ### Floor function example Source: https://github.com/foundryvtt/pf2e/wiki/Quickstart-guide-for-rule-elements Example of using the floor function to scale a modifier based on actor level. ```json { "key": "FlatModifier", "selector": "strike-damage", "damageType": "spirit", "value": "floor(@actor.level/2)" } ```