Re: creating an inventory in BGT
Actually theres a simpler way. You'd create an aray with strings. Now this wouldn't work if your items had special abilities all showed by an inventory, like 2 different sets of armor might have different things, and a class would be better for things in the end because you could drop them, and you could have a boolian spesifying weather it was in your inventory, but you could start with strings.
string[] inv;
inv.insert_last("knife");
inv.insert_last("armor");
inv.insert_last("icecream");
and as for the menu... this is asuming that you have dynamic_menu m;
string invmenu()
{
m.reset(true);
for(uint x=0; x<inv.length(); x++)
{
m.add_item_tts(inv[x], inv[x]);
}
int mres=m.run("Please select an item from your inventory", true);
if(mres==0) // escape
{
return "0";
}
else
{
return m.get_item_name(mres);
}
}
e
sentually, here could be some code you might use for when you select an item.
if(key_pressed(KEY_I))
{
use(invmenu());
}
void use(string item)
{
if(item=="0")
{
return; // they pressed escape.
}
if(item=="key")
{
if(position==doorposition)
{
// unlock code.
}
else
{
// message saying the key can't be used here.
}
}
}
Now note that this was written in a hurry and is far from perfect, but it's just an example of ways you could go about it. That code probably shouldn't be used in the end, but if your looking for a kind of example, there you go. I could have done it way better but that code I wrote, though could contain compolation errors, the logic of that code would somewhat work. Good luck.
_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector