package item
import "git.teletypegames.org/engines/inkwell/item"
Package item holds the Item type and its Manager: the things the player can carry.
An item has a Name to register and look it up by, a Sprite for the inventory and the cursor, a Description the UI shows for it, and Lore, a paragraph for a dossier screen once the item is known. OnUseSelf answers the item used on its own; OnUseWith maps another *Item to what happens when the two are used together — with one in hand, clicking the other in the inventory runs whichever of the two pairs them. An item used on a hotspot is the hotspot's business (its OnUseWith and OnUseWithAny), with the game's UseWithFail as the answer nobody wrote.
The inventory itself remembers items by name and lives on the Game.
Index
Types
type Item
type Item struct { // Name is the key the item is registered under and the inventory holds. Name string // Sprite is the item's picture in the inventory. Sprite *sprite.Sprite // Description is the item's one-line text: what the inventory and the // action log call it, and what the player says on looking at it. An // empty Description falls back to Name. Description inkbase.Text // Lore is what the player's record says about the item once it is // known — a paragraph for a dossier or a codex screen, not the one-line // Description the inventory shows. Nil keeps the item out of such a // screen. Lore inkbase.Text // OnUseSelf is the action for using the item on its own: the player // holds it and clicks it again in the inventory. Nil puts it back. OnUseSelf inkbase.Action // OnUseWith maps another item to the action that runs when the two are // combined in the inventory; either item's map may hold the pairing. Using // an item on a hotspot reads the hotspot's own OnUseWith instead. OnUseWith map[*Item]inkbase.Action }
Item is a thing the player can carry: a name to register and look it up by, a picture for the inventory, a line to show for it, and what happens when it is used on its own or on something else.
func (Item) GetName
func (i Item) GetName() string
GetName returns the item's Name, the key it is registered under.
func (Item) TypeLabel
func (i Item) TypeLabel() string
TypeLabel returns "item", the kind that tells an item apart from other entities of the same Name in saved state and in panic messages.
type Manager
type Manager = inkbase.Manager[*Item]
Manager is the registry of items, keyed by Item.Name and kept in registration order; see inkbase.Manager.
func NewManager
func NewManager() *Manager
NewManager returns an empty Manager of items.