Inventory Aid Documentation

Contents

Introduction

“Inventory Aid” is a plugin for Construct 2 designed to help with the creation of typical game inventories, which can be most famously found in RPGs and related genres. Usually those inventories are grid-based, holding items in each cell.

While this plugin was designed to be easy to use, a basic understanding of Construct 2 is definitely required beforehand. Still I would probably recommend “Inventory Aid” the most to those considering themselves slightly advanced users already.

General info

  • Containers

    Any object holding items is called a container. The player inventory can be a container as well as a chest you’re able to loot. Containers are being defined, spawned and manipulated via the plugin.

    First a container type is defined to which objects can be bound (see “Binding” below). From this definition instances can be created and ultimately spawned.

  • Items
    Any object that can be placed within a container is called an item. Items are being defined, added and removed via the plugin.

    Items also need to be defined first. Instances are being created when added to a container and will spawn with it (given a sprite object is actually bound).

    • Properties

      Items can have any number of properties. A property consists of a name and value.

      For example you could add the property “Durability” to an armor item and decrease its value to make it eventually break.

      Properties can be defined for any previously defined item and need to be of equal value for all items in a stack.

  • Binding 

    While containers and items by themselves are purely logical concepts, you can bind sprites/ text / sprite font objects via the plugin to get a visual respresentation easily.

  • Pools 
    Pools are essentially just lists of items. Items can be added multiple times to the same pool. The main use is to pick randomly selected items from a predefined item group (randomized loot).

Conditions

  • For each item (loop)
    A loop which iterates through all items in a container. Check out the corresponding expressions.
  • For each placement (loop)
    A loop that can be used in combination with the “On placement found”-condition (which may trigger after the “Find placement(s) for item”-action) and iterates for each found placement. Check the corresponding expressions.
  • Is instance spawned
    True when the named container instance has been spawned.
  • Item has property
    True when the property does exist with the named item.
  • On failed to find free cell(s)
    Triggers if no free cells are found after “Find free cells for size”-action.
  • On failed to find placement
    Triggers if no placement is found after “Find placement(s) for item”-action.
  • On free cell(s) found
    Triggers if free cells are found after “Find free cells for size”-action.
  • On instance of type spawned
    Triggers when an instance of a container type is spawned.
  • On placement found for item found
    Triggers if any placement is found after “Find placement(s) for item”-action.
  • On item failed to move
    Triggers if an item couldn’t be moved via the “Move item”-action.
  • On item moved successfully
    Triggers if an item has been moved successfully.

Actions

  • Access cell
    Accesses a container cell by X and Y coordinates and populates related expressions.
  • Access cell by item UID
    Populates related expressions. Useful when picking a cell via a spawned sprite.
  • Add item at
    Adds an item to container instance at given coordinates (if possible).
  • Add item to pool
    Adds an item to an existing pool.
  • Bind 9-patch object to border
    Binds a 9-patch object to a container type to be spawned as its border.
  • Bind object to cells
    Binds a tiled background / sprite (or similar) object to container type to be spawned as the visual grid.
  • Bind object to item
    Binds a sprite (or similar) object to represent the item in a spawned container instance.
  • Bind object to item count
    Binds a text / spritefont (or similar) object to an item to represent its counter.
  • Clear container
    Removes all items from a container.
  • Create container instance
    Creates an instance of a container type.
  • Create pool
    Creates a new pool.
  • Define container
    Defines a container type.
  • Define item
    Defines an item type. Enter its name, width, height and stack size.
  • Define property
    Defines an item property.
  • Drag child counter by parent UID
    Repositions a bound item counter object properly. Useful when moving item sprites around.
  • Find free cells for size
    Attempts to find coordinates to fit a size (width, height) into a container instance. Will trigger one of two conditions and set related expressions.
  • Find placement(s) for item
    Attemps to place an item within a container instance. Will trigger one of two conditions and set related expressions.
  • Load instance state from JSON
    Loads the complete state of a container instance from a JSON string.
  • Load property string
    Loads item properties from a string (property1:value,property2:value,…). Will overwrite all exisiting properties.
  • Move container
    Repositions a spawned container instance.
  • Move instance to top
    Puts a spawned container instance to the top of its layer.
  • Move item
    Attempts to move an item within a container or between different containers. Will trigger one of two conditions.
  • Respawn items
    Respawns all the bound item sprites for a spawned container instance.
  • Return all item objets to position
    Positions all bound item sprites back to their stored position within a spawned container instance.
  • Set property
    Sets the value of a property of a item instance.
  • Set border margins
    Sets the border margins manually. Usually not needed.
  • Spawn container
    Spawns a container instance. All bound objects will be created.
  • Unspawn container
    Destroys the visual respresentation (all bound objects) of a container instance.

Expressions

  • AccessCellSize
    The size of the accessed cell (via an “Access cell”-action) in pixels.
  • AccessCellX
    The X coordinate of the accessed cell.
  • AccessCellY
    The Y coordinate of the accessed cell.
  • AccessContainer
    The name of the accessed container instance.
  • AccessItem
    The name of the accessed item.
  • AsJSON
    The content of a container instance as string.
  • FoundFreeX
    The X coordinate of the first free cell found via the “Find free cells for size”-action.
  • FoundFreeY
    The Y coordinate of the first free cell found via the “Find free cells for size”-action.
  • GetCoordX
    Takes a pixel position (X) and returns the nearest cell coordinate for a container instance.
  • GetCoordY
    Takes a pixel position (Y) and returns the nearest cell coordinate for a container instance.
  • GetPropVal
    Returns the property value of an item instance.
  • ItemHeight
    The height of an item type.
  • ItemWidth
    The width of an item type.
  • LastSpawned
    Returns name of the last spawned container instance.
  • LoopAmount
    Returns item amount in loop (For each item).
  • LoopItem
    Returns item name in loop (For each item).
  • LoopX
    Returns X coordinate of item amount in loop (For each item).
  • LoopY
    Returns X coordinate of item amount in loop (For each item).
  • MovedToName
    Returns name of the container instance an item was last moved to.
  • NameByBorder
    Returns the container instance name by bound border object UID.
  • NameByCell
    Returns the container instance name by bound cell object UID.
  • PlaceAmount
    Returns the current item amount that can be placed within a “For each placement”-loop.
  • PlaceContainer
    Returns the container name that was previously given in “Find placement(s) for item”-action.
  • PlaceItem
    Returns the item name that was previously given in “Find placement(s) for item”-action.
  • PlacePropDiff
    Returns the property string potentially entered in a “Find placement(s) for item”-action.
  • PlaceRest
    Returns the remaning amount of an item that couldn’t be placed via a “Find placement(s) for item”-action.
  • PlaceX
    Returns the current X coordinate within a “For each placement”-loop.
  • PlaceY
    Returns the current Y coordinate within a “For each placement”-loop.
  • PropStrAt
    Returns the property string for item at position (property:value,property:value…).
  • RandItem
    Returns a randomly selected item name from a pool.

Leave a Reply

Your email address will not be published. Required fields are marked *