Class Store
Methods
store:init (data) | Initiate a store from its definition. |
store:generate_items () | Generates the store's inventory |
store:select_missions () | Select missions to offer, if there's a limit |
store:restock () | Restocks the store. |
store:add_item (item, info) | Adds an item to the store. |
store:get_inventory () | Gets a list of the items the store is selling |
store:get_count (item) | Gets the numbers of items this store has in its current inventory that matches a passed item |
store:get_buy_list (creat) | Gets a list of the items that a creature can sell to a store |
store:get_buy_cost (item) | Determines if a store will buy an item, and returns the price if so |
store:creature_sells_item (item, info, cost, amt, creat) | Sell an item to the store |
store:creature_buys_item (item, info, cost, amt, creat) | Buy an item from the store |
store:teach_spell (spellID, creature) | Have a creature learn a spell from a store. |
store:teach_skill (skillID, creature) | Have a creature learn a skill from a store. |
store:get_inventory_index (item) | Gets the index within the store's inventory of the item in question |
store:get_possible_random_items () | Get all possible random items the store can stock |
store:generate_random_item (list) | Generate a random item from the store's possible random items list |
store:get_teachable_spells (creature) | Gets the list of spells the store can teach a given creature |
store:get_teachable_skills (creature) | Gets the list of skills the store can teach a given creature |
store:get_available_missions (creature, ignoreCurrent.) | Gets the list of missions the store can teach a given creature |
store:requires () | Placeholder for the requires() code, which is run to determine if the player can enter the store or not. |
Methods
- store:init (data)
-
Initiate a store from its definition. You shouldn't use this function, the game uses it at loadtime to instantiate the stores.
Parameters:
- data Table. The table of store data.
Returns:
-
self Store. The store itself.
- store:generate_items ()
- Generates the store's inventory
- store:select_missions ()
- Select missions to offer, if there's a limit
- store:restock ()
- Restocks the store. Default behavior: Restock all defined items up to their original amount, unless restock_amount or restock_to is set.
- store:add_item (item, info)
-
Adds an item to the store. If the store already has this item, increase the amount
Parameters:
- item Item. The item to add
- info Table. The information to pass
- store:get_inventory ()
-
Gets a list of the items the store is selling
Returns:
-
Table. The list of items the store has in stock
- store:get_count (item)
-
Gets the numbers of items this store has in its current inventory that matches a passed item
Parameters:
- item Item. The item to count.
Returns:
-
Number. The number of items
- store:get_buy_list (creat)
-
Gets a list of the items that a creature can sell to a store
Parameters:
- creat Creature. The creature selling to the store. Optional, defaults to the player
Returns:
-
Table. The list of items the player can sell, each of which is another table in the format {item=Item,cost=Number}
- store:get_buy_cost (item)
-
Determines if a store will buy an item, and returns the price if so
Parameters:
- item Item. The item to consider
Returns:
-
False or Number. False if the store won't buy it, the price if it will
- store:creature_sells_item (item, info, cost, amt, creat)
-
Sell an item to the store
Parameters:
- item Item. The item being sold
- info Table. A table of information passed by the store screen. Can include:
- cost Number. The amount the store will pay per item.
- amt Number. The amount of the item being sold. Optional, defaults to 1.
- creat Creature. The creature selling to the store. Optional, defaults to the player.
- store:creature_buys_item (item, info, cost, amt, creat)
-
Buy an item from the store
Parameters:
- item Item. The item being sold
- info Table. A table of information passed by the store screen. Can include:
- cost Number. The amount the store is charging per item.
- amt Number. The amount of the item being sold. Optional, defaults to 1.
- creat Creature. The creature selling to the store. Optional, defaults to the player.
Returns:
-
Boolean, Text/nil. True and nil if the buying was successful, False and a string if there's a reason the buying didn't go through.
- store:teach_spell (spellID, creature)
-
Have a creature learn a spell from a store.
Parameters:
- spellID String. The ID of the spell they're trying to learn.
- creature Creature. The creature learning the spell. (optional, defaults to the player)
Returns:
-
Boolean. Whether learning the spell was successful or not.
- store:teach_skill (skillID, creature)
-
Have a creature learn a skill from a store.
Parameters:
- skillID String. The ID of the skill they're trying to learn.
- creature Creature. The creature learning the skill. (optional, defaults to the player)
Returns:
-
Boolean. Whether learning the skill was successful or not.
- store:get_inventory_index (item)
-
Gets the index within the store's inventory of the item in question
Parameters:
- item Item. The item to seach for.
Returns:
- Number. The index ID of the item.
- Number. The amount of the item we have
- store:get_possible_random_items ()
-
Get all possible random items the store can stock
Returns:
-
Table. A list of the item IDs
- store:generate_random_item (list)
-
Generate a random item from the store's possible random items list
Parameters:
- list Table. A list of item IDs to pull from. Optional, defaults to the list from get_possible_random_items()
- store:get_teachable_spells (creature)
-
Gets the list of spells the store can teach a given creature
Parameters:
- creature Creature. Optional, defaults to player
Returns:
-
Table. A list of possible spells
- store:get_teachable_skills (creature)
-
Gets the list of skills the store can teach a given creature
Parameters:
- creature Creature. Optional, defaults to player
Returns:
-
Table. A list of possible skills
- store:get_available_missions (creature, ignoreCurrent.)
-
Gets the list of missions the store can teach a given creature
Parameters:
- creature Creature. Optional, defaults to player
- ignoreCurrent. Optional, if true ignore the current_missions table
Returns:
-
Table. A list of possible missions
- store:requires ()
-
Placeholder for the requires() code, which is run to determine if the player can enter the store or not.
Returns:
-
True.