About Store Forum Documentation Contact



Post Reply 
Get item from Inventory
Author Message
siwykon Offline
Member

Post: #1
Get item from Inventory
Hello!
I have question:
1. How I can check item from inventory, for example: how check that "magic sword" is in inventory. Is any way to do that?
04-17-2011 05:27 AM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #2
RE: Get item from Inventory
In Inventory.h add this in struct Inventory
Code:
Bool    ItemExist    (Str item_name);

In Inventory.cpp add this in global scope
Code:
Bool    Inventory::ItemExist(Str item_name)
{
    REPA(items)
    {
        if(items[i].name==item_name)
        {
            //item found
            //do stuff here
            return true;
        }
    }
    return false;
}

In main.cpp, add this in update()
Code:
if(Kb.bp(KB_G))
        if(InvGui.inv->ItemExist("Club"))
            //You can also do stuffhere
            StateExit.set();
04-17-2011 07:55 AM
Find all posts by this user Quote this message in a reply
siwykon Offline
Member

Post: #3
RE: Get item from Inventory
Big thanks. It work.
(This post was last modified: 04-20-2011 04:33 AM by siwykon.)
04-17-2011 08:02 AM
Find all posts by this user Quote this message in a reply
Post Reply