Class:Stack
Extends: AdventureJS.Atom
Defined in: Adventure/Assets/Helpers/Stack.js, line 5
Tutorials: Helpers_Stacks
Description
Stack is a special class that allows entity assets to be split into In this example, we'll set up a custom class Pistachio and then create a dispenser that spawns new instances.
MyGame.createClass({
class: "Pistachio",
extend: "Edible",
singular: "pistachio",
plural: "pistachios",
description: function () {
let msg = "";
msg = `It's a pistachio. `;
return msg;
},
});
MyGame.createAsset({
class: "Pistachio",
name: "pistachio",
place: { in: "small pouch" },
stack: {
// If use_stack_name is true, this item will be described
// using the enumeration property with the class's singular
// property, eg "three pistachios".
// If use_stack_name is false, the asset's
// name will be used, eg "the sack of pistachios".
// This is intended to help distinguish dispensers.
// Spawned stacks will default to use_stack_name = true.
this.use_stack_name = true;
// enumeration determines how stack numbers are
// presented. Options are:
// numeric: 1, 2, 3, 17, 100, etc.
// spelled: a, two, three, seventeen, one hundred, etc.
// grouped: a, a couple of, several, a few, some, numerous
// The enumeration setting carries to spawned stacks.
this.enumeration = "spelled"; // numeric, spelled, grouped
// Making a stack a dispenser means the whole stack
// is a fixed object. For example,
// a sack of peanuts, where the sack is an asset,
// and the peanuts always reside inside it.
// New peanuts can be spawned from the stack,
// but the entire stack can't be removed.
// Spawned stacks will NOT be dispensers.
dispenser: false,
// Quantity represents the current count of items
// in this stack, which could be 1 or 10 or 1000.
// Setting to -1 makes it infinite which is useful
// for making bottomless dispensers.
quantity: -1,
// max_quantity sets the highest quantity that
// this stack can hold. Setting to -1 makes it
// infinite. If quantity is set to -1, max_quantity
// will be ignored.
max_quantity: -1,
// max_per_take sets the highest quantity that
// can be taken from this stack at a time.
this.max_per_take = -1;
// max_stacks_in_game means the total number of
// stacks allowed in the game world, for
// example you may want to allow no more
// than 50 unique breadcrumbs to be created.
// Spawned stacks will always inherit this property
// from their originating stack.
max_stacks_in_game: 50,
// max_quantity_in_game means the total quantity held
// by all stacks in the game world.
// For instance, you may want to have 5 quivers
// of arrows, but no more than 50 arrows between them all.
// If any stack of this class has infinite quantity,
// this will be infinite.
// Spawned stacks will always inherit this property
// from their originating stack.
max_quantity_in_game: -1,
// Stacks spawned by this stack will inherit properties
// from this stack, except for dispenser and use_stack_name.
// max_quantity and max_per_take can be set uniquely for new stacks.
spawn_properties: {},
},
});
Private Constructor:
var foo = new Stack(game_name, name)
Parameters:
-
game_nameString
Name of top level game instance that is scoped to window. -
nameString
Instance name.
- Index
- Methods
- Properties
Index
Methods:
- Inherited from Atom getClassInheritance
- Inherited from Atom hasClass
- Inherited from Atom Overrides from Atom set
Properties:
Methods Collapse all |
getClassInheritance
getClassInheritance() → {Array}
Defined in: Adventure/Atom.js, line 200
Inherited from: AdventureJS.Atom#getClassInheritance
Returns:
Array
hasClass
hasClass(prop) → {Boolean}
Defined in: Adventure/Atom.js, line 174
Inherited from: AdventureJS.Atom#hasClass
Parameters:
-
propString
Name of the class to test for.
Returns:
Boolean
set
set(props) → {Object}
Defined in: Adventure/Atom.js, line 162
Overrides from: AdventureJS.Atom#set
Parameters:
-
propsObject
A generic object containing properties to copy to the Object instance.
Returns:
Object
Returns the instance the method is called on (useful for chaining calls.)
Properties |
dispenser
dispenser :Boolean
Defined in: Adventure/Assets/Helpers/Stack.js, line 137
enumeration
enumeration :string
Defined in: Adventure/Assets/Helpers/Stack.js, line 126
game
game :Getter
Defined in: Adventure/Atom.js, line 141
Inherited from: AdventureJS.Atom#game
this.game.
id
id :String
Defined in: Adventure/Atom.js, line 117
Inherited from: AdventureJS.Atom#id
max_quantity
max_quantity :int
Defined in: Adventure/Assets/Helpers/Stack.js, line 160
Default value: -1
max_quantity_in_game
max_quantity_in_game :int
Defined in: Adventure/Assets/Helpers/Stack.js, line 191
max_stacks_in_game
max_stacks_in_game :int
Defined in: Adventure/Assets/Helpers/Stack.js, line 180
max_take
max_take :int
Defined in: Adventure/Assets/Helpers/Stack.js, line 170
Default value: -1
name
name :String
Defined in: Adventure/Atom.js, line 62
Overrides from: AdventureJS.Atom#name
Name
Name :String
Defined in: Adventure/Atom.js, line 128
Inherited from: AdventureJS.Atom#Name
quantity
quantity :int
Defined in: Adventure/Assets/Helpers/Stack.js, line 149
Default value: 1
spawn_properties
spawn_properties :object
Defined in: Adventure/Assets/Helpers/Stack.js, line 202
use_stack_name
use_stack_name :Boolean
Defined in: Adventure/Assets/Helpers/Stack.js, line 114