-
Notifications
You must be signed in to change notification settings - Fork 52
Item
MMOMinion edited this page Nov 7, 2013
·
12 revisions
#Item
- An Item is the central word we use for objects the Inventory. Items are returned by the [Inventory] or by Inventory:Get(itemid) for directly accessing it.
- The Item object is a lua metatable itself, meaning it has attributes as well as functions.
- Here we are calling the Inventory to give us all Items of a type 1000 ( all equiped items). The 'd' - debug prints into the console the ID of the Item as well as the Name.
Available filters are type, and category
- Example:
-- type 1000 is your equiped inventory, refer to the InventoryBag enum
local item = Inventory("type=1000")
if ( item) then
local i,item= next(item)
while (i~=nil and item ~=nil) do
-- the 'd' command is a global command for printing out information into the console
d("item: ".. tostring(item.id).. " ItemName: "..item.name)
i,action = next (item,i)
end
end
- The returned item is a lua table.
- The Action attributes can be accessed like this:
-- the 'd' command is a global command for printing out information into the console
d(item.id)
-- returns the ID of that item
d(item.isready)
-- returns true/false if the item is useable
d(item.category)
-- returns the ItemCategory of the item
d(item.bagid)
-- returns the bag id that the item resides in
- name
- Returns Name (string).
- id
- Returns ID (number).
- category
- Returns the ITEMCATEGORY(number).
- slot
- Returns the slot-index of the bag where the item is in(number).
- type
- Returns the INVENTORYTYPE the item is in.
- condition
- Returns the condition of the item
- count
- Returns the stack count of the item.
- max
- Returns maximum stack count
- isready
- Returns if the item can be used(boolean).
- Each Item has functions that can be used directly. In this example we are getting the item with the unique ID "4551", which is generic potion, and we are just use it.
local item= Inventory:Get(4551)
if ( item and item.isready ) then
item:Use()
end
- :Use()
- Use the item on yourself
- :Use(EntityID)
- Attempts to use the item on the specified entity id
- :Repair()
- Repairs the item