Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Sat 29/05/2004 20:06:37

Title: Help with my new inventory!!!
Post by: on Sat 29/05/2004 20:06:37
I want to make a template similar to broken sword's. I am a newbie but I know C++ already so a scripting answer would be difficult for me . So far I have made a GUI  (a bar) which shows up when cursor is on top of the screen. Ok so far. I want this bar to have an icon for save\load\quit menu (I have made this too) which will open as another GUI and the inventory. I have used Add Inventory button to define the inventory area in this bar. When the game starts, the bar shows nothing of my two starting objects.What else must I do so this area behaves as my new inventory? If anyone could show me a starting tip, I would be happy. Thanks
Title: Re: Help with my new inventory!!!
Post by: Skio on Sat 29/05/2004 21:53:42
The inventory item slots have certain dimensions. If the inventory is smaller, the items do not appear.

Open the Global Script (do not panic) and under the "function game_start()", AFTER the {, put the command SetInvDimension(x, y). Look it up in the HELP for better results. This command sets the inv slot dimensions so that they fit in your inventory.

For example, if your inventory is 20x320, the the slot must be no more than 20pixels high, so --> SetInvDimensions(20, 20);

I had the same proble at the beginning. It took me long to discover it!

Good luck!
Title: Re: Help with my new inventory!!!
Post by: on Wed 02/06/2004 09:16:22
Thanks for the answer but I still have a question about the inventory. I want to handle clicks in my inventory area ( remember it's not a separate GUI) so when I left click an inventory object , the cursor becomes it and then use it on a hotspot or another object or character. How can I do that? I have tried to add to on_mouse_click() this:

if (button ==  LEFT)
{
       if (mouse.x>=59) & (mouse.x<=294) & (mouse.y>=4) & (mouse.y<=19) ) // Inventory area
       {
                 SetCursorMode(MODE_USE);
       }
}

but nothing happens and the cursor wont't change.
Please any tip would be helpful.....
Title: Re: Help with my new inventory!!!
Post by: Ashen on Wed 02/06/2004 12:53:44
I think the problem is that you're setting the cursor mode, but not telling it what to do with it. Try this instead:

if (button ==Ã,  LEFT)
{
Ã,  Ã,  Ã,  Ã, if (mouse.x>=59) && (mouse.x<=294) && (mouse.y>=4) && (mouse.y<=19) ) // Inventory area
Ã,  Ã,  Ã,  Ã, {
Ã,  Ã,  Ã,  Ã,  Ã, ProcessClick(mouse.x, mouse.y, MODE_USE);
Ã,  Ã,  Ã,  Ã, }
}

Or if that doesn't work, you could try replacing the ProcessClick with

SetActiveInventory (GetInvAt (mouse.x, mouse.y);
SetCursorMode (MODE_USEINV);

Hopefully, one of these'll work.