Difference between revisions of "Script:Ammo"
From Roll20 Wiki
Andreas J. (Talk | contribs) m (Update info & examples, link to thread) |
Andreas J. (Talk | contribs) m (Sheet-specific examples) |
||
Line 14: | Line 14: | ||
* {{fpl|4543180/ (Script Update) Ammo - Automated ammunition management script}} - 2017 | * {{fpl|4543180/ (Script Update) Ammo - Automated ammunition management script}} - 2017 | ||
+ | |||
+ | [[File:Stargate-ammo-api.png|thumbnail|Example of result in {{Text Chat}}]] | ||
== Commands == | == Commands == | ||
Line 25: | Line 27: | ||
| <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>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'' | + | | <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>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.'' | ||
Line 66: | Line 68: | ||
!wammo @{character_id} arrows -1 arrow | !wammo @{character_id} arrows -1 arrow | ||
</pre> | </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 == | ||
Revision as of 15:26, 16 May 2021
Version: 0.22
Last Modified: 2020-06
Code: Ammo
Dependencies: IsGM
Conflicts: None
This article is a stub. |
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 |
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.
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
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
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