Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Difference between revisions of "Script:Ammo"

From Roll20 Wiki

Jump to: navigation, search
m
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{script overview
+
{{revdate}}{{stub}}
 +
{{main|API:Script Index}}{{script overview
 
|name=Ammo
 
|name=Ammo
|author={{user profile|104025|Aaron C. M.}}
+
|author=[[The Aaron|Aaron C. M.]]
 
|version=0.22
 
|version=0.22
 
|dependencies={{api repository link|IsGM}}
 
|dependencies={{api repository link|IsGM}}
|lastmodified=2015-02-18}}
+
|lastmodified=2020-06}}
{{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.
  
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.''
  
'''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'''
+
* {{fpl|4543180/ (Script Update) Ammo - Automated ammunition management script}} - 2017
  
    !'''ammo'''
+
[[File:Stargate-ammo-api.png|thumbnail|300px|Example of result in {{Text Chat}}]]
        This command requires 3 parameters:
+
          '''id''' -- The id of the character which has the attribute. You can pass this as selected|token_id and the character id will be pulled from represents field of the token.
+
          '''attribute''' -- The name of the attribute representing ammunition.
+
          '''amount''' -- The change to apply to the current quantity of ammo. Use negative numbers to decrease the amount, and possitive numbers to increase it.
+
    '''!get-represents''' [''token_id'']
+
        This command will show the character id for the supplied token id, or will list the character ids for all the selected tokens.
+
    '''token_id''' -- ''The id of the token to lookup, usually supplied with: '''selected|token_id'''''
+
  
<br clear="all">
+
== Commands ==
  
=== Changelog ===
+
:<code>!ammo <id> <attribute> <amount> [resource name]</code>
 +
::This command requires 3 parameters to process correctly, as shown above.
 +
:::{| class="wikitable"
 +
|-
 +
! 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


Main Page: API:Script Index

API ScriptAuthor: Aaron C. M.
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.

Example of result in q Text Chat

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 index
amount 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.

[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

Stargate-ammo-api.png

[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