mouse-scroll throught inventory objects.

This is a public forum, where you can find out everything you wanted to know about making games. Please don't use this forum as a place to recruit new members.

Moderators: adeyke, VampD3, eriqchang, Angelus3K

Post Reply
Message
Author
rich_eter
Peasant Status
Posts: 44
Joined: Thu Mar 31, 2005 9:51 am
Contact:

mouse-scroll throught inventory objects.

#1 Post by rich_eter » Sat Nov 18, 2006 6:08 am

I've seen that you guys (AGDI) have add this feature your recent game[s] so I'd like to know how you coded it. If you use the scroll mouse wheel while you have an inventory item selected as your mouse mode, it will go to to the next inventory item automatically...

how did you code this?

rich_eter
Peasant Status
Posts: 44
Joined: Thu Mar 31, 2005 9:51 am
Contact:

#2 Post by rich_eter » Tue Nov 21, 2006 9:51 am

BUMP!

I'm certain this much is right...

somewhere in:
function on_mouse_click(...

if (mouse.Mode==eModeUseinv) { //then...
 if (button==WHEELNORTH) {
   //scroll up;
 }
 if (button==WHEELSOUTH) {
   //scroll down through the inventory...
 }
}

So, the part I'm can't figure out is obviously the missing parts. I can't find how to script changing the active inventory item. I'd really appreciate help on filling in the blanks.

p.s. I always return favors when people are nice to me.

Music Head
Defense Minister Status
Posts: 717
Joined: Sun Aug 15, 2004 3:55 am
Location: South Australia

#3 Post by Music Head » Tue Nov 21, 2006 12:12 pm

I don't often see replies from the AGDI's on the forums so I'm not sure they check them much. You might be better off asking how to do this on the AGS forums.

rich_eter
Peasant Status
Posts: 44
Joined: Thu Mar 31, 2005 9:51 am
Contact:

#4 Post by rich_eter » Tue Nov 21, 2006 6:52 pm

Yeah, you're probably right.

It's cool though. I figured out how to do it on my own late last night. :)

pass
Royal Servant Status
Posts: 129
Joined: Wed Mar 22, 2006 8:38 pm
Location: Israel

#5 Post by pass » Thu Nov 23, 2006 9:03 pm

Care to share?  ;)

Klytos
Infamous Sheik of Australia
Posts: 1722
Joined: Tue Apr 22, 2003 3:43 pm
Location: Rockhampton Australia
Contact:

#6 Post by Klytos » Mon Nov 27, 2006 8:29 am

Code: Select all

  

else if (mouse.Mode==eModeUseinv) { 
// this bit will allow mousewheel to scroll through inventory if the 
// mouse.Mode is set to use inventory;

int tempInv=character[EGO].ActiveInventory.ID;
int maxInv=25;  

//set maxinv to the maximum inventory items;
    
    if (button==WHEELNORTH) {

      if (tempInv==1)
        tempInv=maxInv;
      else
        tempInv--;
      while(character[EGO].InventoryQuantity[tempInv]==0) { 

//checks to see if the Player has this item

        if (tempInv==1)
          tempInv=maxInv;
        else
          tempInv--;
      }
      character[EGO].ActiveInventory=inventory[tempInv];
    }
    else if (button==WHEELSOUTH) {
      if (tempInv==maxInv)
        tempInv=1;
      else
        tempInv++;
      while(character[EGO].InventoryQuantity[tempInv]==0) { 

//checks to see if the Player has this item

        if (tempInv==maxInv)
          tempInv=1;
        else
          tempInv++;
      }
      character[EGO].ActiveInventory=inventory[tempInv];
    }
  } //end the section for scrolling through inventory

Post Reply