Skip to content

GwenTastic/Chapbook-Addon-Collection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Gwen's Chapbook Addon Collection

Installing the addon

To install the addon simply copy and paste the contents of the .js file into your Story's JavaScript page.

{List Collection: <collection> [, DisplayName: <string>] [, Detailed: <string>] [, AllowCount: true] [, Divider: ]}

Takes in an array or object collection to display it's contents as a list.
Source Code: ListCollection.js

Arguments:

  • <collection> [Mandetory] the array or object of the collection which contents you want to be listed.
  • DisplayName [Optional, only Objects] overwrites the default property .Name or .name that it looks for to display as name, which allows you to select any other property.
  • Detailed [Optional, only Objects] takes in additional object property names to be displayed, multiple property names are simply separated by a space. There is a build in keyword all which will list all properties (except for the DisplayName choosen property).
  • AllowCount [Optional, for Arrays and Objects] will display a number at the front of the list which represents the index of the item inside the collection.
  • Divider [Optional, for Arrays and Objects] will change the default divider " - ".

Example Code:

Display an Array Inventory:

inventory: ["An apple", "A banana"]
--
{List Collection: inventory}

Expected Output:

An apple
A banana

Display an Array Inventory with counted numbers:

inventory: ["An apple", "A banana"]
--
{List Collection: inventory, AllowCount: true}

Expected Output:

1 - An apple
2 - A banana

Display an Object Inventory but show Color instead of the Name property:

inventory: {Strawberries: {Name: "Strawberries", Count: 2, Color: "red", Value: 10}, Cherries: {Name: "Cherries", Count: 4, Color: "darkred", Value: 36}}
--
{List Collection: inventory, DisplayName: "Color"}

Expected Output:

red
darkred

Display an Object Inventory but with additional selected Properties (Color and Count):

inventory: {Strawberries: {Name: "Strawberries", Count: 2, Color: "red", Value: 10}, Cherries: {Name: "Cherries", Count: 4, Color: "darkred", Value: 36}}
--
name - color - item count  <br>
{List Collection: inventory, Detailed: "Color Count"}

Expected Output:

name - color - item count
Strawberries - red - 2
Cherries - darkred - 4

Display an Object Inventory with Detailed: "all" property which will show all properties:

inventory: {Strawberries: {Name: "Strawberries", Count: 2, Color: "red", Value: 10}, Cherries: {Name: "Cherries", Count: 4, Color: "darkred", Value: 36}}
--
inv. nr. - name - item count - color - value
{List Collection: inventory, Detailed: "all", AllowCount: true}

Expected Output:

inv. nr. - name - item count - color - value
1 - Strawberries - 2 - red - 10
2 - Cherries - 4 - darkred - 36

Display Object Inventory with changed divider symbol:

inventory: {Strawberries: {Name: "Strawberries", Count: 2, Color: "red", Value: 10}, Cherries: {Name: "Cherries", Count: 4, Color: "darkred", Value: 36}}
--
inv. nr. - name - item count - color - value <br>
{List Collection: inventory2, Divider: " :: ", AllowCount: true, Detailed: "all"}

Expected Output:

inv. nr. - name - item count - color - value
1 :: Strawberries :: 2 :: red :: 10 2 :: Cherries :: 4 :: darkred :: 36

About

Gwens Chapbook Addons

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published