Inventory GUI problem

Started by HillBilly, Thu 05/02/2004 07:20:15

Previous topic - Next topic

HillBilly

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:

Code: ags

  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

Ishmael

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...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

HillBilly

erm... where's my on_mouse_click function?  :-X

Ishmael

I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Darth Mandarb

Technical Archive:
Custom Inventory GUI Thread

You might find what you need in there!

~ d

HillBilly

Quote from: Darth Mandarb on Thu 05/02/2004 18:22:56
Technical Archive:
Custom Inventory GUI Thread

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:

Code: ags
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.

Ishmael

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?
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

HillBilly

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...

strazer

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.

HillBilly

You mean like this?

Code: ags
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.

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


I've also tried using

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

Ytterbium

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.

Currently in production: Septigon

HillBilly

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.

HillBilly

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

Dorcan

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;
   }

HillBilly

Thanks. Still, there is a small bug with the inventory: When i insert this script:

Code: ags

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?

Dorcan

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.

HillBilly


SMF spam blocked by CleanTalk