Class engine.generator.interface.ActorInventory

Handles actors stats

Methods

engine.generator.interface.ActorInventory:defineInventory (short_name, name, is_worn, desc, show_equip, infos)

Defines an Inventory slot Static!

engine.generator.interface.ActorInventory:init (t)

Initialises inventories with default values if needed

engine.generator.interface.ActorInventory:initBody (max)

generate inventories according to the body definition table

engine.generator.interface.ActorInventory:getInven (id)

Returns the content of an inventory as a table

engine.generator.interface.ActorInventory:canAddToInven (id)

Tells if an inventory still has room left

engine.generator.interface.ActorInventory:invenStackLimit (id)

Get stacking limit for an inventory

engine.generator.interface.ActorInventory:addObject (inven_id, o, no_unstack, force_item)

Adds an object to an inventory checks o:on_preaddobject(self, inven) (must return true to add to inventory)

engine.generator.interface.ActorInventory:itemPosition (inven, o, by_reference)

Returns the position of an item in the given inventory, or nil

engine.generator.interface.ActorInventory:pickupFloor (i, vocal, no_sort)

Pick up an object from the floor
checks obj:onprepickup(self, i) (must return true to pickup)
checks obj:on
pickup(self, num) and self:onpickupobject(obj, num) functions after pickup (includes stacks)

engine.generator.interface.ActorInventory:removeObject (inven_id, item, no_unstack)

Removes an object from inventory checks obj:on_preremoveobject(self, inven) (return true to not remove)

engine.generator.interface.ActorInventory:onAddObject (o, inven_id, item)

Called upon adding an object

engine.generator.interface.ActorInventory:onRemoveObject (o, inven_id, item)

Called upon removing an object

engine.generator.interface.ActorInventory:onDropObject (o)

Called upon dropping an object

engine.generator.interface.ActorInventory:dropFloor (inven, item, vocal, all)

Drop an object on the floor checks item:on_drop(self) (return true to not drop)

engine.generator.interface.ActorInventory:showEquipInven (title, filter, action, on_select)

Show combined equipment/inventory dialog

engine.generator.interface.ActorInventory:showInventory (title, inven, filter, action)

Show inventory dialog

engine.generator.interface.ActorInventory:showEquipment (title, filter, action)

Show equipment dialog

engine.generator.interface.ActorInventory:showPickupFloor (title, filter, action)

Show floor pickup dialog

engine.generator.interface.ActorInventory:canWearObject (o, try_slot)

Can we wear this item?

engine.generator.interface.ActorInventory:slotForbidCheck (o, in_inven_id)

Checks if the given item should respect its slot_forbid value

engine.generator.interface.ActorInventory:getObjectOffslot (o)

Returns the possible offslot

engine.generator.interface.ActorInventory:wearObject (o, replace, vocal, force_inven, force_item)

Wear/wield an item checks o:on_canwear(self, inven) (return true to prevent wearing)

engine.generator.interface.ActorInventory:takeoffObject (inven_id, item)

Takeoff item

engine.generator.interface.ActorInventory:onWear (o, inven_id)

Call when an object is worn

engine.generator.interface.ActorInventory:onTakeoff (o, inven_id)

Call when an object is taken off

engine.generator.interface.ActorInventory:sortInven (inven)

Re-order inventory, sorting and stacking it sort order is type > subtype > name > getNumber()

engine.generator.interface.ActorInventory:findInInventory (inven, name, getname)

Finds an object by name in an inventory

engine.generator.interface.ActorInventory:findInAllInventories (name, getname)

Finds an object by name in all the actor's inventories

engine.generator.interface.ActorInventory:findInInventoryBy (inven, prop, value)

Finds an object by property in an inventory

engine.generator.interface.ActorInventory:findInAllInventoriesBy (prop, value)

Finds an object by property in all the actor's inventories

engine.generator.interface.ActorInventory:findInInventoryByObject (inven, so)

Finds an object by reference in an inventory

engine.generator.interface.ActorInventory:findInAllInventoriesByObject (so)

Finds an object by reference in all the actor's inventories

engine.generator.interface.ActorInventory:inventoryApply (inven, fct)

Applies fct over all items

engine.generator.interface.ActorInventory:inventoryApplyAll (fct)

Applies fct over all items in all inventories

engine.generator.interface.ActorInventory:forgetInven (inven)

Empties given inventory and marks items inside as never generated



Methods

engine.generator.interface.ActorInventory:defineInventory (short_name, name, is_worn, desc, show_equip, infos)
Defines an Inventory slot Static!

Parameters:

  • short_name = name for reference (required)
  • name = name used for messages (required)
  • is_worn = boolean true if equipment can be worn in this inventory
  • desc = description (required)
  • show_equip = boolean to show inventory when displaying equipment dialogs
  • infos = additional information (including default stack_limit)
engine.generator.interface.ActorInventory:init (t)
Initialises inventories with default values if needed

Parameters:

  • t
engine.generator.interface.ActorInventory:initBody (max)
generate inventories according to the body definition table

Parameters:

  • max = number of slots if number or table of properties (max = , stack_limit = , ..) merged into definition
engine.generator.interface.ActorInventory:getInven (id)
Returns the content of an inventory as a table

Parameters:

  • id
engine.generator.interface.ActorInventory:canAddToInven (id)
Tells if an inventory still has room left

Parameters:

  • id
engine.generator.interface.ActorInventory:invenStackLimit (id)
Get stacking limit for an inventory

Parameters:

  • id inventory id or table (stack_limit in inventory table takes precedence)
engine.generator.interface.ActorInventory:addObject (inven_id, o, no_unstack, force_item)
Adds an object to an inventory checks o:on_preaddobject(self, inven) (must return true to add to inventory)

Parameters:

  • inven_id = inventory id to add to
  • o = object to add
  • no_unstack = boolean to prevent unstacking the object to be added
  • force_item to add to the set position instead of to the end

Returns:

    false if the object could not be added

Or

  1. true
  2. inventory index it was moved to
  3. remaining stack if any or false
engine.generator.interface.ActorInventory:itemPosition (inven, o, by_reference)
Returns the position of an item in the given inventory, or nil

Parameters:

  • inven = inventory or inventory id to search
  • o = object to look for
  • by_reference set true to match by exact (memory) reference, otherwise matches by o.name

Returns:

    nil

Or

  1. the inventory slot
  2. stack position if stacked
engine.generator.interface.ActorInventory:pickupFloor (i, vocal, no_sort)
Pick up an object from the floor
checks obj:onprepickup(self, i) (must return true to pickup)
checks obj:on
pickup(self, num) and self:onpickupobject(obj, num) functions after pickup (includes stacks)

Parameters:

  • i object position on map at self.x, self.y
  • vocal boolean to post messages to log
  • no_sort boolean suppress automatic sorting of inventory. puts picked up objects in self.INVEN_INVEN

Returns:

    nil

Or

    true if o:on_prepickup(i) returns true (not "skip")

Or

  1. the object picked up (or stack added to)
  2. num picked up
engine.generator.interface.ActorInventory:removeObject (inven_id, item, no_unstack)
Removes an object from inventory checks obj:on_preremoveobject(self, inven) (return true to not remove)

Parameters:

  • inven_id the inventory to remove from
  • item inven slot of the item to remove
  • no_unstack num items to remove into a new stack (set true to remove the original stack unchanged)

Returns:

  1. nil if no item existed
  2. a boolean saying if there is no more objects

Or

    the object removed
engine.generator.interface.ActorInventory:onAddObject (o, inven_id, item)
Called upon adding an object

Parameters:

  • o
  • inven_id
  • item
engine.generator.interface.ActorInventory:onRemoveObject (o, inven_id, item)
Called upon removing an object

Parameters:

  • o
  • inven_id
  • item
engine.generator.interface.ActorInventory:onDropObject (o)
Called upon dropping an object

Parameters:

  • o
engine.generator.interface.ActorInventory:dropFloor (inven, item, vocal, all)
Drop an object on the floor checks item:on_drop(self) (return true to not drop)

Parameters:

  • inven the inventory to drop from
  • item the item id to drop
  • vocal do we show a log message on dropping?
  • all set to remove part (if number) or all (if true) a stack

Returns:

    the object removed or nil if no item existed
engine.generator.interface.ActorInventory:showEquipInven (title, filter, action, on_select)
Show combined equipment/inventory dialog

Parameters:

  • title title of the dialog
  • filter nil or a function that filters the objects to list
  • action a function called when an object is selected
  • on_select the function to be called on selecting the item
engine.generator.interface.ActorInventory:showInventory (title, inven, filter, action)
Show inventory dialog

Parameters:

  • title title of the dialog
  • inven the inventory (from self:getInven())
  • filter nil or a function that filters the objects to list
  • action a function called when an object is selected
engine.generator.interface.ActorInventory:showEquipment (title, filter, action)
Show equipment dialog

Parameters:

  • title title of the dialog
  • filter nil or a function that filters the objects to list
  • action a function called when an object is selected
engine.generator.interface.ActorInventory:showPickupFloor (title, filter, action)
Show floor pickup dialog

Parameters:

  • title title of the dialog
  • filter nil or a function that filters the objects to list
  • action a function called when an object is selected
engine.generator.interface.ActorInventory:canWearObject (o, try_slot)
Can we wear this item? checks self:canWearObjectCustom(o, try_slot) (return true to make unwearable)

Parameters:

  • o object to wear
  • try_slot inventory slot to wear (override)
engine.generator.interface.ActorInventory:slotForbidCheck (o, in_inven_id)
Checks if the given item should respect its slot_forbid value

Parameters:

  • o the item to check
  • in_inven_id the inventory id in which the item is worn or tries to be worn
engine.generator.interface.ActorInventory:getObjectOffslot (o)
Returns the possible offslot

Parameters:

  • o
engine.generator.interface.ActorInventory:wearObject (o, replace, vocal, force_inven, force_item)
Wear/wield an item checks o:on_canwear(self, inven) (return true to prevent wearing)

Parameters:

  • o object to be worn
  • replace boolean allow first object in wearable inventory to be removed to make space if needed
  • vocal boolean to post messages to game.logSeen(self, ....)
  • force_inven boolean try to equip into this inventory only
  • force_item boolean attempt to equip/replace into that slot

Returns:

    false

Or

  1. true
  2. remaining stack of o if any

Or

  1. replaced object if succeeded
  2. remaining stack of o if any
engine.generator.interface.ActorInventory:takeoffObject (inven_id, item)
Takeoff item

Parameters:

  • inven_id = inventory id
  • item = slot to remove from checks obj:on_cantakeoff(self, inven) (return true to prevent taking off)
engine.generator.interface.ActorInventory:onWear (o, inven_id)
Call when an object is worn

Parameters:

  • o = object being worn
  • inven_id = inventory id checks o:onwear(self, invenid)
engine.generator.interface.ActorInventory:onTakeoff (o, inven_id)
Call when an object is taken off

Parameters:

  • o = object being taken off
  • inven_id = inventory id checks o:ontakeoff(self, invenid)
engine.generator.interface.ActorInventory:sortInven (inven)
Re-order inventory, sorting and stacking it sort order is type > subtype > name > getNumber()

Parameters:

  • inven
engine.generator.interface.ActorInventory:findInInventory (inven, name, getname)
Finds an object by name in an inventory

Parameters:

  • inven the inventory to look into
  • name the name to look for
  • getname optional table the parameters to pass to getName(), if nil the default is {nocount=true, forceid=true}

Returns:

    nil if not found

Or

  1. object
  2. position
engine.generator.interface.ActorInventory:findInAllInventories (name, getname)
Finds an object by name in all the actor's inventories

Parameters:

  • name the name to look for
  • getname the parameters to pass to getName(), if nil the default is {nocount=true, forceid=true}

Returns:

    nil if not found

Or

  1. object
  2. position
  3. inven_id
engine.generator.interface.ActorInventory:findInInventoryBy (inven, prop, value)
Finds an object by property in an inventory

Parameters:

  • inven the inventory to look into
  • prop the property to look for
  • value the value to look for, can be a function

Returns:

    nil if not found

Or

  1. object
  2. position
engine.generator.interface.ActorInventory:findInAllInventoriesBy (prop, value)
Finds an object by property in all the actor's inventories

Parameters:

  • prop the property to look for
  • value the value to look for, can be a function

Returns:

    nil if not found

Or

  1. object
  2. position
  3. inven_id
engine.generator.interface.ActorInventory:findInInventoryByObject (inven, so)
Finds an object by reference in an inventory

Parameters:

  • inven the inventory to look into
  • so the object(reference) to look for

Returns:

    nil if not found

Or

  1. object
  2. position
engine.generator.interface.ActorInventory:findInAllInventoriesByObject (so)
Finds an object by reference in all the actor's inventories

Parameters:

  • so the object(reference) to look for

Returns:

    nil if not found

Or

  1. object
  2. position
  3. inven_id
engine.generator.interface.ActorInventory:inventoryApply (inven, fct)
Applies fct over all items

Parameters:

  • inven the inventory to look into
  • fct func the function to be called. It will receive three parameters: inven, item, object
engine.generator.interface.ActorInventory:inventoryApplyAll (fct)
Applies fct over all items in all inventories

Parameters:

  • fct func the function to be called. It will receive three parameters: inven, item, object
engine.generator.interface.ActorInventory:forgetInven (inven)
Empties given inventory and marks items inside as never generated

Parameters:

  • inven the inventory to empty
generated by LDoc 1.4.3