Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: HillBilly on Thu 05/02/2004 07:20:15

Title: Inventory GUI problem
Post by: HillBilly on Thu 05/02/2004 07:20:15
Right, I've been snooking around in the technical archive a bit, and i came over this toturial: http://www.digitalmindstudio.ch/script.php?id=4&langue=en

Yeah, that seemed alright. But i wanted to create the inventory at the bottom of the screen, so i had to do some changes. Still, when i try to pick up an object, it won't go to the inventory box. There is probably some n00bish solution on this, since i'm such a crappy coder. This is the script i used:


 if (interface == 2) {
   if   ( button == 1 )     {   //"Use" button
     SetCursorMode ( 3 ) ;
     SetMouseCursor ( 2 ) ;
   }   else
   if  ( button == 4 )   {   //"Up" arrow
     if  ( game.top_inv_item > 0 )
       game.top_inv_item = game.top_inv_item - game.items_per_line;      
   }  else
   if  ( button == 5 )   {   //"Down" arrow
     if  ( game.top_inv_item < game.num_inv_items - game.num_inv_displayed )
       game.top_inv_item = game.top_inv_item + game.items_per_line;          
   }

 }  // end if interface 2


I havn't fixed the up and down buttons yet, wich should be left and right buttons. I need to get the inventory to work first, so i can be sure it works.

You can download my GUI here:
http://hbw.stickthemepark.com/ImagesHost/BG/sillygui.gui
Title: Re:Inventory GUI problem
Post by: Ishmael on Thu 05/02/2004 07:58:38
Hmm...... checked the "Handle inventory clicks in script" in the general settings? If you have, post your on_mouse_click function here, if you haven't, post that function here anyway and try if checking it does anything...
Title: Re:Inventory GUI problem
Post by: HillBilly on Thu 05/02/2004 17:53:40
erm... where's my on_mouse_click function?  :-X
Title: Re:Inventory GUI problem
Post by: Ishmael on Thu 05/02/2004 17:57:52
In the global script...
Title: Re:Inventory GUI problem
Post by: Darth Mandarb on Thu 05/02/2004 18:22:56
Technical Archive:
Custom Inventory GUI Thread (http://www.agsforums.com/yabb/index.php?board=10;action=display;threadid=10946;start=new;boardseen=1)

You might find what you need in there!

~ d
Title: Re:Inventory GUI problem
Post by: HillBilly on Thu 05/02/2004 19:04:29
Quote from: Darth Mandarb on Thu 05/02/2004 18:22:56
Technical Archive:
Custom Inventory GUI Thread (http://www.agsforums.com/yabb/index.php?board=10;action=display;threadid=10946;start=new;boardseen=1)

You might find what you need in there!

~ d

Where do you think i got the toturial from?  ;)

Quote from: TK on Thu 05/02/2004 17:57:52
In the global script...

Oh, right. You have to exuse me, it's been years and days since I've been using AGS. Hardly remember anything.

Here ye go:

function on_mouse_click(int button) {
 // called when a mouse button is clicked. button is either LEFT or RIGHT
 if (IsGamePaused() == 1) {
   // Game is paused, so do nothing (ie. don't allow mouse click)
 }
 else if (button==LEFT) {
   ProcessClick(mouse.x, mouse.y, GetCursorMode() );
 }
 else {   // right-click, so cycle cursor
   SetNextCursorMode();
 }
}


Atleast i think that's right, only on_mouse_click i found.
Title: Re:Inventory GUI problem
Post by: Ishmael on Thu 05/02/2004 19:47:09
HHHMMMMMmmm...... I really can't say what's wrong then...

QuoteStill, when i try to pick up an object, it won't go to the inventory box.

???:o::):-[

Has it been a shortcut in my head, or do you mean, that when you AddInventory(1);, inventory item 1 doesn't appear in the inventory window you have created?
Title: Re:Inventory GUI problem
Post by: HillBilly on Thu 05/02/2004 20:40:11
yes! I've also tried to check "player starts with this inventory item at start". Don't work. There is probably some obvious error I havn't discovered...
Title: Re:Inventory GUI problem
Post by: strazer on Thu 05/02/2004 21:00:06
If the inventory window is smaller than the inventory items, they won't be displayed.
Try either resizing the inventory or fiddle around with the SetInvDimensions function.
Title: Re:Inventory GUI problem
Post by: HillBilly on Fri 06/02/2004 06:48:34
You mean like this?

function game_start (  )   {
 // called when the game starts, before the first room is loaded
 SetInvDimensions ( 40,40 ) ;
}


Hell, it worked. Toh, the "use" button still don't work.

   if   ( button == 1 )     {   //"Use" button
     SetCursorMode ( 3 ) ;
     SetMouseCursor ( 2 ) ;
   }   else


I've also tried using

   if   ( button == 1 )     {   //"Use" button
     SetCursorMode ( 2 ) ;
     SetMouseCursor ( 2 ) ;
   }   else
Title: Re:Inventory GUI problem
Post by: Ytterbium on Sat 07/02/2004 04:09:15
Quote from: HillBilly on Fri 06/02/2004 06:48:34

Hell, it worked. Toh, the "use" button still don't work.

That's probably because the Use action defaults to selecting inventory items. Try not setting the Use button to be the actual Use interaction, but rather some other inventory-specific cursor mode, and setting use interactions to be triggered by that.


Either that, or I'm stupid.
Title: Re:Inventory GUI problem
Post by: HillBilly on Sat 07/02/2004 08:41:54
Well, I did that. The script i used changed the cursor to use, but used the programming to "talk".

To quote the toturial:

Quote
Why have we chosen the "Talk" mode for the "use" action? Simply because the "interract" mode is used to select an inventory object.
Of course, if we want to create an interraction for an object, we must choose Talk to inventory item instead of interact inventory item in the Interaction Editor window.
Title: Re:Inventory GUI problem
Post by: HillBilly on Sun 08/02/2004 09:48:24
Right, I've fixed the most important stuff, but there is still some errors:

The buttons(look at, interact, pick up etc): works fine
Up and down buttons: When i click down, the GUI turns black.
Inventory: Only displays one row at top, should be 2 rows.

GUI download:
http://hbw.stickthemepark.com/ImagesHost/BG/inventorygui.gui
Title: Re:Inventory GUI problem
Post by: Dorcan on Sun 08/02/2004 10:22:55
According to the GUI I downloaded, your GUI buttons numbers doesn't match your GUI script :

Button 3 is the down arrow :

if (button == 3) {
     // They pressed the OK button, close the GUI
     GUIOff (INVENTORY);
     SetDefaultCursor();
   }

Button 4 is the UP arrow :

   if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
     // scroll down
     game.top_inv_item = game.top_inv_item + game.items_per_line;
   }


Button 5 is the Talk button :

   if ((button ==5) && (game.top_inv_item > 0)){
     // scroll up
     game.top_inv_item = game.top_inv_item - game.items_per_line;
   }
Title: Re:Inventory GUI problem
Post by: HillBilly on Sun 08/02/2004 10:48:29
Thanks. Still, there is a small bug with the inventory: When i insert this script:


function game_start (  )   {
 // called when the game starts, before the first room is loaded
 SetInvDimensions ( 20,20 ) ;
}

In the global script, it shows 2 rows, but the inventory items don't get smaller. Instead they get closer together. Is there any way to fix this, or do i need to redraw the inventory items smaller?
Title: Re:Inventory GUI problem
Post by: Dorcan on Sun 08/02/2004 11:08:02
SetInvDimensions only change the size of each area that will contain the inventory object. Unfortunately, you will have to redraw your objects... or make your inventory square larger.
Title: Re:Inventory GUI problem
Post by: HillBilly on Sun 08/02/2004 11:20:29
Okay, thanks.