Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: strangechicken on Thu 02/12/2010 12:29:40

Title: Cursor won't change to inventory item
Post by: strangechicken on Thu 02/12/2010 12:29:40
Hey guys,

I'm having an issue with my inventory... I can click on an object... which in turn gives me an inventory item... thats all grand....

But I can't use my inventory at all... I have the "when mouse moves to the top of screen"  Visibility setting... Which comes down showing my inventory as it should when i get to the the top... all good.. but when I try to click an Item, where the function should be for the cursor should be to change to the selected item... it just does nothing, so I can't use my inventory at all... because I can't take items out of it for use...

I am using Khris's Broken sword style script which can be found here:  http://www.adventuregamestudio.co.uk/yabb/index.php?topic=35247.0...

and it all works fine... except this blasted inventory which is practically unclickable

Here is my script on the issue:

Quote
function on_mouse_click(MouseButton 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 == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight){
    // right-click
    if (mouse.Mode == eModeUseinv) mouse.Mode = eModeWalkto;   // loose inv item
    else ProcessClick(mouse.x, mouse.y, eModeLookat);             // or look at ...
  }
  else if (button == eMouseMiddle) {
    // Middle-button-click, default make character walk to clicked area (a little shortcut)
    // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
    // leave our options open - what if you have a special script triggered
    // on "walking" mode?
    ProcessClick(mouse.x, mouse.y, eModeWalkto);
  }
  else if (button == eMouseLeftInv) {
    if (mouse.Mode == eModeUseinv) inventory[game.inv_activated].RunInteraction(eModeUseinv);
    else {
      player.ActiveInventory = inventory[game.inv_activated];
      // mouse.Mode = eModeUseinv;
    }
  }
  else if (button == eMouseRightInv) {
    if (mouse.Mode == eModeUseinv) mouse.Mode = eModePointer;
    else inventory[game.inv_activated].RunInteraction(eModeLookat);
  }
}

Please be gentle... I don't have much experience with this, any feedback would be appreciated

Aaron.
Title: Re: Cursor won't change to inventory item
Post by: Dualnames on Thu 02/12/2010 12:57:58
Find something called Override built in sth on general settings pane under inventory section and set it to true. That should do it.
Title: Re: Cursor won't change to inventory item
Post by: strangechicken on Thu 02/12/2010 15:45:42
Quote from: Dualnames on Thu 02/12/2010 12:57:58
Find something called Override built in sth on general settings pane under inventory section and set it to true. That should do it.

I looked but cannot find the thing you described.. theres only four things under inventory "Display Multiple Icons for multiple items" (which is on false), Handle inventory clicks in script (which is on true), "inventory item hotspot marker" (which is on none) and "use selected inventory graphic for cursor "(which is on true).... I am using ags 3.1.2 if that helps any.

Aaron.
Title: Re: Cursor won't change to inventory item
Post by: Dualnames on Thu 02/12/2010 16:08:52
I think it's handle inventory script. Set it to false.

What Khris said.

EDIT: Oh, man why did Chris changed this to 3.2.0 and confuse me?!
Title: Re: Cursor won't change to inventory item
Post by: Khris on Thu 02/12/2010 17:11:13
No, it's supposed to be set to true. We WANT to handle inv clicks in script.

My script disables mouse clicks if the game is paused. It might be that the "when mouse moves to the top of screen" setting pauses the game, not sure.
Try this version of on_mouse_click:

function on_mouse_click(MouseButton button) {

  if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight){
    // right-click
    if (mouse.Mode == eModeUseinv) mouse.Mode = eModeWalkto;   // loose inv item
    else ProcessClick(mouse.x, mouse.y, eModeLookat);             // or look at ...
  }
  else if (button == eMouseMiddle) {
    // Middle-button-click, default make character walk to clicked area (a little shortcut)
    // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
    // leave our options open - what if you have a special script triggered
    // on "walking" mode?
    ProcessClick(mouse.x, mouse.y, eModeWalkto);
  }
  else if (button == eMouseLeftInv) {
    if (mouse.Mode == eModeUseinv) inventory[game.inv_activated].RunInteraction(eModeUseinv);
    else {
      player.ActiveInventory = inventory[game.inv_activated];
      // mouse.Mode = eModeUseinv;
    }
  }
  else if (button == eMouseRightInv) {
    if (mouse.Mode == eModeUseinv) mouse.Mode = eModePointer;
    else inventory[game.inv_activated].RunInteraction(eModeLookat);
  }
}
Title: Re: Cursor won't change to inventory item
Post by: strangechicken on Thu 02/12/2010 17:31:39
Tried that.. still nothing... this is turnin out to be such a hasle :(
Title: Re: Cursor won't change to inventory item
Post by: Khris on Thu 02/12/2010 17:46:07
How big are your inv items? If you open the inv GUI and select the InventoryWindow, what does it say for ItemWidth/Height? Is the GUI clickable?
Title: Re: Cursor won't change to inventory item
Post by: strangechicken on Thu 02/12/2010 17:54:29
20 x 30 it says...

and GUI is clickable
Title: Re: Cursor won't change to inventory item
Post by: Khris on Thu 02/12/2010 20:19:59
Hmm, I guess the easiest way is if you uploaded the game somewhere. I promise I won't do anything bad with your resources. At this point, looking at the source will make finding a solution much quicker and easier for me.
Title: Re: Cursor won't change to inventory item
Post by: strangechicken on Thu 02/12/2010 20:24:53
Hey, I got it working for now.. thankyou all for your patience...

*is excited*

Alright... now one small step for noob... on giant leap for noobkind...

Lets get this game on the road
Title: Re: Cursor won't change to inventory item
Post by: Khris on Thu 02/12/2010 22:37:31
So, for future reference, was did you do to fix it?
Title: Re: Cursor won't change to inventory item
Post by: strangechicken on Fri 03/12/2010 07:28:38
I think it was that my Images... were too big for the set items in the inventory... so after changing the sizes to fit my inventory images... and fiddling around with things.. I have handle inventory clicks in script turned on for instance... it just worked for some reason...
Title: Re: Cursor won't change to inventory item
Post by: strangechicken on Fri 03/12/2010 07:31:53
I'll clarify... my thing was set tto 30 x 20 i believe.. so i changed it to 64 x 83 (my image size), and that got it going