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:Backpack"

From Roll20 Wiki

Jump to: navigation, search
(weight)
(description)
Line 124: Line 124:
  
 
=== description ===
 
=== description ===
 +
The description argument is optional, typically containing some textual information regarding the item. It follows the syntax <code>desc:(<text>)</code> where <code><text></code> is anything except parenthesis. Valid examples include:
 +
 +
<code>desc:(This old hat was once worn by haggard the great)</code><br>
 +
<code>desc:(This artifact was one of the 4 shards spread across the continent. It radiates a dim red light around its edges..)</code>
 +
 
=== use ===
 
=== use ===
 
=== charges ===
 
=== charges ===

Revision as of 04:25, 26 June 2015

API Script Author: Ken L.
Version: 1.25
Last Modified: 2015-6-24
Code: NA
Dependencies: None
Conflicts: Unknown

Contents

Backpack is a journal based inventory system that updates the 'bio' section of a journal to represent a graphic inventory interface. This allows GMs whom implement this script to allow players to manage a graphic representation of their inventory. Once setup, you can move, give, drop, and pickup items through the use of the API button interface as well as buy and sell from shops and stores should they be prepared.

To use this script requires quite a bit of setup on the part of the GM preparing the asset and item databases. The asset database is simply a list of available item types/subtypes and their associated images. The item database is a list of parsable item definitions which can be short hand written to loot drops or any backpack compatible journal entry.


Getting Started

Once you load the backpack.js and backpack_tmp.js scripts into your campaign, you'll need to at least create an asset database.

After creating an asset database, you're ready to populate backpack compatible journal entries as inventories, stores, or loot cache drops.

General Use

TODO

Item Definitions

Item definitions are the format in which entries of items are parsed into the script. They consist of several parts.

[quantity] <name>;<type> [weight] [value] [description] [use] [maxcharge] [enigma]
Formally:

[quantity] name

type
[optionals] 

[quantity] name

type
subtype
[optionals] 


name

→ Name of the item, see name

type

→ Existing type in backpack_tmp.js, see type

sybtype

→ Existing subtype defined in the asset database, see subtype

quantity

Optional quantity of the item, see quantity

weight

Optional weight of the item in lbs, see weight

value

Optional value of the item, see value

description

Optional description of the item, see description

use

Optional use argument to be executed, see use

maxcharge

Optional max charges of the item, see charges

enigma

Optional enigma arguments, see enigmas

name

The name parameter is essential to the item definition and must be unique for this item. Names of items are case insensitive and considered first class citizens along with enigma names. Names can contain any character including numbers but cannot start with a number else that number will be considered a quantity.

Names have a special suffix case where if it has a suffix of [<number>] it can denote charges. In this case the name of the item is everything preceding this suffix. For the example of 'Wand of Bless[50]', 'Wand of Bless' is the base item name, and '[50]' is parsed out as the number of charges this item has. This is such that items of the same charge amount can stack and separate in quantity as they're used. Clearly an item named 'Staff of bots' and 'Staff of bolts[10]' would be seen as the same item; but one definition denotes that the item has charges, and the other does not, 'Staff of bolts' is not the same as 'Staff of bolts[0]' despite having the same name identifier. For the purposes of charging this item, 'Staff of bolts[0]' could be charged and 'Staff of bolts' could not.

If there are multiple items with the same name identifier the combined result of the receiving location will have its quantity increased even if the donating location's item definition is different in other areas from the receiving location's definition.

An example would be moving a 'flute' from AB where say A has 5 flutes and B has 2 flutes. The difference between A and B's flutes despite having the same name is that they have different descriptions or weights despite having the same primary identifier as 'flute'. If you move 1 flute AB then B would have 3 flutes and A 4 as expected, but B will simply have it's quantity altered, as opposed to another 'flute' item being generated matching A's flute definition.

A simple resolution to this to have the name be more descriptive such as 'Alfreds Flute' and 'Bernard's Flute'. Special care must be taken such that these names do not conflict with introduced enigma names

type

The type parameter is essential to the item definition as it connects the item definition to a display template that exists in backpack_tmp.js as well as an image for the type. A legal type is defined within the script, therefore only a fixed number of types exist. This can be extended upon by editing backpack_tmp.js, see customizing for details. All types are case sensitive and can only include characters [A-Za-z] plus '-' and '_'.

Type name Description
potion template for potions
weapon template for weapons
armor template for armor
wand template for potions
staff template for staves
ring template for rings
scroll template for scrolls
misc template for miscellaneous
food template for food
treasure template for treasure
gem template for gems

No item definition can exist without a valid type, compared to subtypes which are optional, and enumerable within the asset database .

subtype

The subtype is not essential to to the item definition so long as the type it branches off exists. Subtypes exist primarily for the purpose of image enumeration categorized by type. For example from scroll:scroll_ancient we can extract scroll as the type and scroll_ancient as the subtype. scroll:scroll_ancient could refer to a withered image of parchment where as scroll:scroll_empowered could refer to an image of a glowing scroll. There are no naming conventions other than what is a legal type name so weapon:greataxe is valid as well.

Types (type and subtype) as presented by this script are used to

A.) Provide a template for the item
B.) Allow propagation for item images related to the base type

quantity

The quantity of an item is optional to the item definition but is never left undefined. If not provided it represents an infinite pool of the item for backpack journals configured as stores, but otherwise defaults to 1 for all other purposes (loot caches, inventories). If defined, the quantity is defined before the item name, typically a white space separating the two.

weight

The weight of an item is optional and considered 0, or weightless if not provided. Weight is parsed as a number immediately followed by lb or lbs. Valid examples are 45lbs or 0.5lb or even 100lb as plurality isn't a factor.

value

The value of an item is represented as the combination of numbers followed by short-hand names of the currency denominations defined in the script's design section. By default these denominations are platinum, gold, silver and copper. Their respective short names are thus 'pp', 'gp', 'sp', and 'cp'. Therefore the value of an item can be represented by the example 10gp 2sp 1cp or 35pp 353gp or even 42098gp 2004sp 350000cp.

Internally, when the script processes the item definition, it unifies the value into a single total and upon display, will divide this unified value into the minimum of each denomination required. Upon saving this item definition this minimum coinage value is recorded as opposed to the original representation.

The denomination values are defined internally in the script's design section. This and currency names can be altered as explained in customizing.

description

The description argument is optional, typically containing some textual information regarding the item. It follows the syntax desc:(<text>) where <text> is anything except parenthesis. Valid examples include:

desc:(This old hat was once worn by haggard the great)
desc:(This artifact was one of the 4 shards spread across the continent. It radiates a dim red light around its edges..)

use

charges

enigmas

Asset Database

The asset database is a journal entry that contains within its gmnotes section the library of images to be used for item definitions through their type and subtype

The asset database has a simple format where each line is a single asset entry (blank lines between groups of entries are fine).

Each asset entry is in either of the following formats:

<type>:<link>
<type>:<subtype>:<link>
Formally:

type

subtype
link


type

link



type

→ Existing type in backpack_tmp.js

sybtype

→ Anything except ε

link

→ HTML link to the image source, must start with 'http' case insensitive

Item Database

TODO

Customizing

TODO

Changelog

TODO