Well, it is quite simple. I want to use them to cycle through my inventory items.
ATTENTION not through my inventory I can do that. I need to use the wheel to cycle my items.
This will cycle through the inventory items in the order they appear in AGSEdit:
function inv_scroll(bool down) {
InventoryItem*item=player.ActiveInventory;
if (item==null) return;
int i=item.ID;
int ni=0;
while(ni==0) {
if (down) i++;
else i--;
if (i>Game.InventoryItemCount) i=1;
if (i<1) i=Game.InventoryItemCount;
if (player.InventoryQuantity[i]>0) ni=i;
}
player.ActiveInventory=inventory[ni];
}
// on_mouse_click
...
else if (button==eMouseWheelNorth) inv_scroll(false);
else if (button==eMouseWheelSouth) inv_scroll(true);
...
You could also use InvWindow.ItemAtIndex and InvWindow.ItemCount to scroll through them in the order they're in your inventory:
int i; // declare outside of function
function inv_scroll(bool down) {
if (down) i --;
else i++;
if (i < 0) i = invCustomInv.ItemCount - 1;
if (i >= invCustomInv.ItemCount) i = 0;
player.ActiveInventory = invCustomInv.ItemAtIndex[i];
}
// on_mouse_click bit stays the same
I don't think there's any practical difference, this is just a little shorter as it skips the need to chack if the player has the item.
Gee thanks buddy.