I'm trying to handle click/right-click events somewhat differently from the AGS default, and am running in to trouble getting inventory clicks recognized. I have a custom inventory bar on the bottom of the screen which is always displayed (and I do have "handle inventory clicks in script" set to "true"), and the logic seems to be acknowledging and responding to clicks upon it sometimes, but not others!
here is the relevant code:
function on_mouse_click(MouseButton button)
{
// "is the game paused" and other logic is here
InventoryItem *i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
LocationType loc = GetLocationType(mouse.x, mouse.y);
if(i != null)
{
Display("clicked on an item!"); // the code gets to this point when I click an item
}
if(button == eMouseRight) // right-click is always "look at"
{
if(i != null)
{
Display("right-clicked on an item."); // the code does NOT get to this point!
// some more code in here, but it's beside the point
}
// there's a bunch more code in here, but it's beside the point
}
else if(button == eMouseLeft) // left click is always an interaction
{
if(i != null)
{
Display("left-clicked on an item."); // the code does NOT get to this point!
// more irrelevant code
the "button" variable seems to be being evaluated correctly, because I can get responses out of clicking and right clicking on other objects (following the "if(i != null)" block there are "else if(loc == eLocationObject)" blocks, and others, which are reached.
it _seems_ like the "i" variable is somehow getting cleared, but that doesn't make any sense! there must be something else I'm missing... any help would be greatly appreciated
[edit] oh, and because I worried that having two "Display" calls in rapid succession might somehow mess with things, I did try removing the first Display("clicked on an item!"); however this has not helped anything.
here is the relevant code:
function on_mouse_click(MouseButton button)
{
// "is the game paused" and other logic is here
InventoryItem *i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
LocationType loc = GetLocationType(mouse.x, mouse.y);
if(i != null)
{
Display("clicked on an item!"); // the code gets to this point when I click an item
}
if(button == eMouseRight) // right-click is always "look at"
{
if(i != null)
{
Display("right-clicked on an item."); // the code does NOT get to this point!
// some more code in here, but it's beside the point
}
// there's a bunch more code in here, but it's beside the point
}
else if(button == eMouseLeft) // left click is always an interaction
{
if(i != null)
{
Display("left-clicked on an item."); // the code does NOT get to this point!
// more irrelevant code
the "button" variable seems to be being evaluated correctly, because I can get responses out of clicking and right clicking on other objects (following the "if(i != null)" block there are "else if(loc == eLocationObject)" blocks, and others, which are reached.
it _seems_ like the "i" variable is somehow getting cleared, but that doesn't make any sense! there must be something else I'm missing... any help would be greatly appreciated

[edit] oh, and because I worried that having two "Display" calls in rapid succession might somehow mess with things, I did try removing the first Display("clicked on an item!"); however this has not helped anything.