Difference between revisions of "Script:Ammo"
From Roll20 Wiki
Andreas J. (Talk | contribs) m |
Andreas J. (Talk | contribs) m (Update info & examples, link to thread) |
||
Line 1: | Line 1: | ||
{{script overview | {{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}} |
{{stub}} | {{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 | + | '''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 | |
− | + | == 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 23: | ||
! 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'' |
|- | |- | ||
− | | | + | | <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. | ||
+ | |||
+ | ===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> | ||
+ | == 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}} |
Revision as of 15:03, 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.
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 nameamount
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
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