Difference between revisions of "Script:Backpack"
From Roll20 Wiki
(→name) |
(→name) |
||
Line 50: | Line 50: | ||
The name parameter is '''essential''' to the item definition and must be unique for this item. Names of items are ''case insensitive'' and considered <u>first class citizens</u> along with [[Script:Backpack#enigmas|enigma]] names. Names can contain any character including numbers but <b>cannot</b> start with a number else that number will be considered a [[Script:Backpack#quantity|quantity]]. | The name parameter is '''essential''' to the item definition and must be unique for this item. Names of items are ''case insensitive'' and considered <u>first class citizens</u> along with [[Script:Backpack#enigmas|enigma]] names. Names can contain any character including numbers but <b>cannot</b> start with a number else that number will be considered a [[Script:Backpack#quantity|quantity]]. | ||
− | Names have a special suffix case where if it has a suffix of <code>[<number>]</code> it can denote charges. In this case the name of the item is everything preceding this suffix. For the example of <code> | + | Names have a special suffix case where if it has a suffix of <code>[<number>]</code> it can denote charges. In this case the name of the item is everything preceding this suffix. For the example of <code>'Wand of Bless[50]'</code>, <code>'Wand of Bless'</code> is the base item name, and <code>'[50]'</code> is parsed out as the number of [[Script:Backpack#charges|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 <code>'Staff of bots'</code> and <code>'Staff of bolts[10]'</code> would be seen as the same item; but one definition denotes that the item has charges, and the other does not, <code>'Staff of bolts'</code> is not the same as <code>'Staff of bolts[0]'</code> despite having the same name identifier. For the purposes of [[Script:Backpack#charges|charging]] this item, <code>'Staff of bolts[0]'</code> could be charged and <code>'Staff of bolts'</code> 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. | 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. |
Revision as of 02:22, 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 A → B 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 A → B 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
subtype
quantity
weight
value
description
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
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