Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Akumayo on Sun 11/09/2005 18:53:09

Title: Scrolling Inventory (Solved)
Post by: Akumayo on Sun 11/09/2005 18:53:09
Okay, another inventory question, how DO you script scrolling inventory buttons, I cannot fathom it...
Title: Re: Scrolling Inventory
Post by: strazer on Sun 11/09/2005 19:30:36
Putting YourInvWindow.ScrollUp() resp. YourInvWindow.ScrollDown() in the GUI button scripts should do it.
Title: Re: Scrolling Inventory
Post by: Akumayo on Sun 11/09/2005 19:45:49
script is:

Ã,  if (interface == INVENTORY) {
Ã,  Ã,  // They clicked a button on the Inventory GUI
Ã,  Ã,  if (button == 6) {
Ã,  Ã,  Ã,  0.ScrollUp();
Ã,  Ã,  }
Ã,  Ã,  if (button == 7) {
Ã,  Ã,  Ã,  0.ScrollDown();
Ã,  Ã,  }

recieve error:Ã,  PEO4 Parse error at "0"

NOTE:  "0" is the GUI object inventory window.
Title: Re: Scrolling Inventory
Post by: strazer on Sun 11/09/2005 19:48:51
You have to give the InvWindows control a name in the editor first. If you want to access it with its number (ID) only, you have to do:

  gYourgui.Controls[0].ScrollUp();
or
  gui[1].Controls[0].ScrollUp();
if you don't want to use the GUI's name.
Title: Re: Scrolling Inventory
Post by: Akumayo on Sun 11/09/2005 19:53:55
Thanks, but yet another error....

  if (interface == INVENTORY) {
    // They clicked a button on the Inventory GUI
    if (button == 6) {
       INVENTORY.Controls[0].ScrollUp();
    }
    if (button == 7) {
       INVENTORY.Controls[0].ScrollDown();
    }

Unexpected '.' possible missing simicolen.
Title: Re: Scrolling Inventory
Post by: strazer on Sun 11/09/2005 19:54:34
INVENTORY => gInventory

Edit:

Oh, and I think it's

gInventory.Controls[0].AsInvWindow.ScrollUp();

Edit 2:

But as I said, it's easier to just give the InvWindow a name in the editor, then you can access it directly:

TheInvWindowControlNameYouGaveItInTheEditor.ScrollUp();
Title: Re: Scrolling Inventory
Post by: Akumayo on Sun 11/09/2005 19:59:53
I know this is probably a stupid question, but how do you give it a name in the editor  ???
Title: Re: Scrolling Inventory
Post by: strazer on Sun 11/09/2005 20:03:32
You use AGS v2.7, yes?
Go to the "GUIs" pane in the editor, select the InvWindow control and in the small floating window, double-click the "Script name" row.
Title: Re: Scrolling Inventory
Post by: Akumayo on Sun 11/09/2005 20:10:17
I have no idea what I'm doing.Ã,  Bear with me....

I can't find the InvWindow control, I don't know if it has anything to do with it, but I'm using a Custom Inventory Window called INVENTORY.

I tried the new script, getting error:Ã,  gInventory as an undefined token.

NOW!!!  AT the worst possible time, yet another problem has sprung up!!!  GRRRRRRR  I accidently created a second inventory window within GUI INVENTORY, and now all my items appear twice, how do you kill a window?
Title: Re: Scrolling Inventory
Post by: strazer on Sun 11/09/2005 20:28:16
Quote from: Akumayo on Sun 11/09/2005 20:10:17I can't find the InvWindow control

Well...it's a rectangular-shaped control. When it's selected, the small floating window's title should say "GUI 2 Control 0 (Inventory)" (as opposed to (Button)) or some such.

Quote from: strazer on Sun 11/09/2005 20:03:32You use AGS v2.7, yes?

Meaning, what version of AGS are you using? .ScrollUp and -Down work with AGS v2.7+ only.

Why don't you take a look at the default game (Start new game, select "Default game" template) to see how the scrolling is done there?

Quote from: Akumayo on Sun 11/09/2005 20:10:17I accidently created a second inventory window within GUI INVENTORY, and now all my items appear twice, how do you kill a window?

Select the GUI control, then press the [DEL] key on your keyboard.
Title: Re: Scrolling Inventory
Post by: Akumayo on Sun 11/09/2005 20:36:18
Thanks for all your help, I'll look up the default scrolling buttons.
Title: Re: Scrolling Inventory (new problem)
Post by: Akumayo on Sun 11/09/2005 23:30:29
New problem...

Here's the script:

      if ((button == 6) && (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;
    }
    if ((button == 7) && (game.top_inv_item > 0)){
      // scroll up
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    }

The game will scroll DOWN when I tell it too, but I can't get it to scroll back UP.  What am I missing here?

BTW:  I'm working off version 6.62
Title: Re: Scrolling Inventory (new problem)
Post by: strazer on Sun 11/09/2005 23:45:08
Are you sure you're pressing the correct button (no. 7)? Make sure by putting a
  // scroll up
    Display("Up pressed");
in there.
Title: Re: Scrolling Inventory (new problem)
Post by: Akumayo on Sun 11/09/2005 23:47:54
I cannot believe I made such a simple mistake!!!  :-[
Thanks so much for your help strazer, it all works now!!!  My inventory issues are solved!  ;D
Title: Re: Scrolling Inventory (new problem)
Post by: strazer on Mon 12/09/2005 00:23:26
Cool. :)