siwykon
Member
|
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 |
|
Dandruff
Member
|
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 |
|
siwykon
Member
|
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 |
|