Difference between revisions of "Script:Ammo"
From Roll20 Wiki
Andreas J. (Talk | contribs) m |
Andreas J. (Talk | contribs) m |
||
(5 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | {{script overview | + | {{revdate}}{{stub}} |
+ | {{main|API:Script Index}}{{script overview | ||
|name=Ammo | |name=Ammo | ||
− | |author= | + | |author=[[The Aaron|Aaron C. M.]] |
|version=0.22 | |version=0.22 | ||
|dependencies={{api repository link|IsGM}} | |dependencies={{api repository link|IsGM}} | ||
− | |lastmodified= | + | |lastmodified=2020-06}} |
− | + | '''Ammo''' provides inventory management for ammunition stored in a character attribute. If the adjustment would change the attribute to be below 0 or above it's maximum value, a warning will be issued and the attribute will not be changed. | |
− | + | :'''Note''': ''As the [[GM]], bounds will not be enforced for you. You will be whispered the warnings, but the operation will succeed. You will also be told the previous and current state in case you want to revert the change.'' | |
Script is sheet-agnostic, and can be made to work with any system. | Script is sheet-agnostic, and can be made to work with any system. | ||
− | + | * {{fpl|4543180/ (Script Update) Ammo - Automated ammunition management script}} - 2017 | |
− | + | [[File:Stargate-ammo-api.png|thumbnail|300px|Example of result in {{Text Chat}}]] | |
− | : | + | == Commands == |
+ | |||
+ | :<code>!ammo <id> <attribute> <amount> [resource name]</code> | ||
::This command requires 3 parameters to process correctly, as shown above. | ::This command requires 3 parameters to process correctly, as shown above. | ||
:::{| class="wikitable" | :::{| class="wikitable" | ||
Line 21: | Line 24: | ||
! Parameters !! Description | ! Parameters !! Description | ||
|- | |- | ||
− | | | + | | <code>id</code> || ''The id of the character which has the attribute. You can pass this as <code>@{character_id}</code>, or <code>@{selected|token_id}</code> if your [[token]] is set to represent a character. See [[Link Token & Sheet]]'' |
|- | |- | ||
− | | | + | | <code>attribute</code> || ''The name of the attribute representing ammunition. Note: this is the name without <code>@{ }</code> around it. This works with [[Repeating Sections|repeating sections]] as well, but you will need to find the repeating rowid to build the attribute name, or use the row index'' |
|- | |- | ||
− | | | + | | <code>amount</code>|| ''The change to apply to the current quantity of ammo. Use negative numbers to decrease the amount, and positive numbers to increase it. You can use [[Inline Rolls|inline rolls]] to determine the number.'' |
|- | |- | ||
− | | | + | | <code>resource name</code>|| ''Anything you put after the amount to adjust by will be used as the resource name (default: "ammo").'' |
− | + | ||
− | + | ||
− | + | ||
− | : | + | |
|- | |- | ||
− | |||
− | |||
− | |||
|} | |} | ||
− | |||
− | |||
− | === | + | <code>!wammo <id> <attribute> <amount> [resource name]</code> |
+ | |||
+ | This command is identical to <code>!ammo</code>, but will whisper all output. | ||
+ | {{apiboxRec}} | ||
+ | ===Examples=== | ||
+ | Shoot 1 arrow: | ||
+ | <pre> | ||
+ | !ammo @{character_id} arrows -1 arrow | ||
+ | </pre> | ||
+ | Shoot 3 arrows: | ||
+ | <pre> | ||
+ | !ammo @{character_id} arrows -3 arrow | ||
+ | </pre> | ||
+ | Recover 1d6 arrows: | ||
+ | <pre> | ||
+ | !ammo @{character_id} arrows [[1d6]] arrow | ||
+ | </pre> | ||
+ | Refill all arrows (by picking up the difference between the current and max value). | ||
+ | <pre> | ||
+ | !ammo @{character_id} arrows [[@{selected|arrows|max}-@{selected|arrows}]] | ||
+ | </pre> | ||
+ | Using a repeating group's field with rowid: | ||
+ | <pre> | ||
+ | !ammo @{character_id} repeating_weapons_-J1as31234_weapon_arrows -1 arrows | ||
+ | </pre> | ||
+ | Using a repeating group's field with index: | ||
+ | <pre> | ||
+ | !ammo @{character_id} repeating_weapons_$2_weapon_arrows -1 arrows | ||
+ | </pre> | ||
+ | Whisper ammo changes to yourself: | ||
+ | <pre> | ||
+ | !wammo @{character_id} arrows -1 arrow | ||
+ | </pre> | ||
+ | ===Examples - Sheet-specific=== | ||
+ | |||
+ | [[D&D 5E by Roll20]] recover 1d4 crossbow bolts (second row of items in the inventory) | ||
+ | <pre> | ||
+ | !ammo @{selected|token_id} repeating_inventory_$1_itemcount [[1d4]] bolts | ||
+ | </pre> | ||
+ | |||
+ | [[Genefunk 2090]], reduce the quantity of the first item in the "Equipment" section by one. | ||
+ | <pre> | ||
+ | !ammo @{selected|token_id} repeating_equipment_$0_quantity -1 Shotgun Shells | ||
+ | </pre> | ||
+ | |||
+ | [[Stargate RPG]], reduce amount of ammo1 by <code>2d6</code>, whispering result to self | ||
+ | <pre> | ||
+ | !wammo @{selected|token_id} ammo1 -[[2d6]] FN P90 | ||
+ | </pre> | ||
+ | [[File:Stargate-ammo-api.png]] | ||
+ | == Changelog == | ||
+ | |||
+ | {{changelog version|0.3.11|2020-06|* {{repo|Roll20/roll20-api-scripts/pull/1000 PR}} }} | ||
+ | {{changelog version|0.3.6|2017|* Made attribute lookups case insensitive. (Thanks Black Falcon!)}} | ||
+ | {{changelog version|0.3.5|2017|* Added <code>!wammo</code> command which whispers the output instead of sending it to chat (Thanks Elena S.!)}} | ||
+ | {{changelog version|0.3.4|2017|* Added resource name and indexed repeating row support (thanks Elena S.!)}} | ||
{{changelog version|0.22|2015-02-18|* -}} | {{changelog version|0.22|2015-02-18|* -}} | ||
{{changelog version|0.21|2015-02-18|* -}} | {{changelog version|0.21|2015-02-18|* -}} | ||
{{changelog version|0.2|2015-02-01|* Release}} | {{changelog version|0.2|2015-02-01|* Release}} | ||
+ | |||
+ | =See Also= | ||
+ | * [[Script:ChatSetAttr]] | ||
+ | <br><br> | ||
+ | [[Category:Character Sheets]] |
Latest revision as of 10:03, 18 February 2022
Page Updated: 2022-02-18 |
This article is a stub. |
Version: 0.22
Last Modified: 2020-06
Code: Ammo
Dependencies: IsGM
Conflicts: None
Ammo provides inventory management for ammunition stored in a character attribute. If the adjustment would change the attribute to be below 0 or above it's maximum value, a warning will be issued and the attribute will not be changed.
- Note: As the GM, bounds will not be enforced for you. You will be whispered the warnings, but the operation will succeed. You will also be told the previous and current state in case you want to revert the change.
Script is sheet-agnostic, and can be made to work with any system.
Contents |
[edit] Commands
!ammo <id> <attribute> <amount> [resource name]
- This command requires 3 parameters to process correctly, as shown above.
Parameters Description id
token_id} if your token is set to represent a character. See Link Token & Sheet attribute
The name of the attribute representing ammunition. Note: this is the name without @{ }
around it. This works with repeating sections as well, but you will need to find the repeating rowid to build the attribute name, or use the row indexamount
The change to apply to the current quantity of ammo. Use negative numbers to decrease the amount, and positive numbers to increase it. You can use inline rolls to determine the number. resource name
Anything you put after the amount to adjust by will be used as the resource name (default: "ammo").
!wammo <id> <attribute> <amount> [resource name]
This command is identical to !ammo
, but will whisper all output.
Roll20 Mod
Mod Suggestions
- D&D 5E
- Combat
- Character Sheet
- Dynamic Lighting
- Jukebox
- Maps
- Text Chat/Macros
- Tokens
- System Specific
- Mod Guides by Script
Debug
Other
[edit] Examples
Shoot 1 arrow:
!ammo @{character_id} arrows -1 arrow
Shoot 3 arrows:
!ammo @{character_id} arrows -3 arrow
Recover 1d6 arrows:
!ammo @{character_id} arrows [[1d6]] arrow
Refill all arrows (by picking up the difference between the current and max value).
!ammo @{character_id} arrows [[@{selected|arrows|max}-@{selected|arrows}]]
Using a repeating group's field with rowid:
!ammo @{character_id} repeating_weapons_-J1as31234_weapon_arrows -1 arrows
Using a repeating group's field with index:
!ammo @{character_id} repeating_weapons_$2_weapon_arrows -1 arrows
Whisper ammo changes to yourself:
!wammo @{character_id} arrows -1 arrow
[edit] Examples - Sheet-specific
D&D 5E by Roll20 recover 1d4 crossbow bolts (second row of items in the inventory)
!ammo @{selected|token_id} repeating_inventory_$1_itemcount [[1d4]] bolts
Genefunk 2090, reduce the quantity of the first item in the "Equipment" section by one.
!ammo @{selected|token_id} repeating_equipment_$0_quantity -1 Shotgun Shells
Stargate RPG, reduce amount of ammo1 by 2d6
, whispering result to self
!wammo @{selected|token_id} ammo1 -[[2d6]] FN P90
[edit] Changelog
v0.3.11 (2020-06)
v0.3.6 (2017)
- Made attribute lookups case insensitive. (Thanks Black Falcon!)
v0.3.5 (2017)
- Added
!wammo
command which whispers the output instead of sending it to chat (Thanks Elena S.!)
v0.3.4 (2017)
- Added resource name and indexed repeating row support (thanks Elena S.!)
v0.22 (2015-02-18)
- -
v0.21 (2015-02-18)
- -
v0.2 (2015-02-01)
- Release
[edit] See Also