Scrolling your inventory (SOLVED)

Started by Susanog, Sun 23/10/2005 11:33:52

Previous topic - Next topic

Susanog

I've search the forums for an answer. Tried everything I can think of, but with no luck. So, I'm asking this - please don't kill me

I've downloaded a 2.7 ags verson of a monkey island 2 gui template, but when I have more than 8 items in my inventory, it doesn't let me scroll down. When I press the scroll down button, the next line of inventory items flashes on for a split second, and then goes back to the first line.

Here's what I've got:
if (button == 9) { // UP arrow
Ã,  Ã,  if (game.top_inv_item>0)
Ã,  Ã,  game.top_inv_item=game.top_inv_item-game.items_per_line;
Ã,  Ã, } else
Ã,  if (button == 10) { // 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;
Ã,  Ã, }
Ã,  }
I've changed it so many times trying to get it to work, that this isn't the original i started with. Another problem is it might be some other coding amoung the hundreds of lines of coding thats screwing me around :(
I can't understand it. I'm so use to the older version of ags, and the new one confuses me. This should be working!!

Please tell me what's wrong with it.

Ashen

#1
I think a lot of the game.XXX variables (particularly the inventory ones) have been obsolete-d for 2.7, so the problem probably lies there (see this thread for another example).

Instead, in 2.7, I would use the InvWindow.ScrollUp/Down commands.
I know what you're thinking ... Don't think that.

Susanog

Please can you write down what it should look like. I replaced everything with the InvWindow.ScrollUp/Down  command to look like:

if (button == 9) { // UP arrow
    if InvWindow.ScrollUp
   } else
  if (button == 10) { // DOWN arrow
    if InvWindow.ScrollDown

This really doesn't make sense to me. CJ should never have changed the coding when people were just getting use to the old version. PLEASE HELP

Thanx

Ashen

#3
You need to give the Inventory Window a script name, in the editor (e.g. MainInv), then it'd be:

if (button == 9)  MainInv.ScrollUp(); // UP arrow
else if (button == 10) MainInv.ScrollDown(); // DOWN arrow

Although, as of 2.7, interface_click (where I'd guess this code is) is obsolete as well. It still works, but as good practice you should be naming the controls (buttons, inv windows, sliders, etc), and creating their individual control functions. (Once you've given the control a script name, just double click it to create/edit the function).
I know what you're thinking ... Don't think that.

Susanog

Arggh... :(

I did it just like you wrote it.

Now it says -

unexpected '.': possible missing semicolon

Ashen

It should work (and does, in a test ame I made), unless there's something else in the template you're using.
Can you post the lines before and after it, as well?
I know what you're thinking ... Don't think that.

Susanog

It must have been something I was doing with the script. As soon as I started a new game and used the scrollup/down coding, it worked. I must have done something funny before without noticing.

The only thing I changed was the inventory item dimensions. That might have screwed it up somehow, seeing the coding is different with 2.7

Sorry for all the fuss

Lazarus

I hadÃ,  the same problem you mentioned about, then I realized that I had set my game up for 640x480 and had moved both Action and Actiongui down the screen. I had forgot to change in the global script

from:
#define FIRST_INV_SLOT_COORDS    Ã,  Ã,  180,160

To in my case:
#define FIRST_INV_SLOT_COORDS    Ã,  Ã,  170,205

Hope this helps
*Currently using AGS Editor 2.70 (Build 2.70.601)*

Susanog

You know what!!! Thats what it was. Thanks, I'll remember that for next time

SMF spam blocked by CleanTalk