I had a visible inventory in my game and I wanted inventory items to be active when you left-click on it. I managed to do this.
Then, I tryed to make an exception: I want my inventory item to be active if I left click it, except if the lookAt cursor is active. If the lookAt cursor is actvive I want the function "inventoryitem_look()" to happen. But I don't know how to make it happen. So, here is my script:
if (button == eMouseLeftInv)
{
if (mouse.Mode == eModeLookat)
{ ??? }
else
{
player.ActiveInventory = inventory[ game.inv_activated ];
}
Is this the right way to do what I want? And if so, what do I have to put instead of the ??? smiley between the two brackets? I want it to be a generic function, so that every inventory item I look at, that function happens.
Thanks!
You can replace the smiley with this line:
inventory[game.inv_activated].RunInteraction(mouse.Mode);
This will run the interaction of the current cursor mode, which is - in your case - the look mode
This is how I'd do it:
if (button == eMouseLeftInv) {
InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (Mouse.Mode == eModeLookat) item.RunInteraction(eModeLookat);
else player.ActiveInventory = item;
}
And remember to set "Handle inventory clicks in script" on the General Settings to true (but judging from your post I guess you know that).
I had some problems and I couldn't read your answers before.
Thank you both for help, I used the first solution and it works perfectly!