I'm using a BASS inventory system and I want to be able to activate the inventory objects with a right mouse click.
I've tried several diffrent approches to this and everyone has been insuccessful.
function on_mouse_click(MouseButton button) {
Ã, ...
Ã, else if (button==eMouseRightInv) {
Ã, Ã, player.ActiveInventory=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
Ã, Ã, Mouse.Mode=eModeUseinv;
Ã, }
}
I've tried this one. The reason I couldn't use this on_mouse_click functions on the inv GUI was that I had Popup Modal activated. I changed it to normal but my main problem still remains..
How do I make the invThingie dissapear after any click and how can I use an object
used this on 'use inventory on hotspot'
if (cEgo.ActiveInventory==iobject) {
Ã, cEgo.Say("Used object on hotspot");
}
tnx
Have you checked the 'Handle inventory clicks in script' option? You need to, to be able to use the eMouseRightInv button option khrismuc showed. I think you'll also need to check that there IS an inventory item at the mouse coords, before setting the active inv, e.g.
if (button == eMouseRightInv) {
InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (item != null) {
player.ActiveInventory = item;
mouse.Mode = eModeUseinv;
// Although, I think this is automatically set when you change active inventory
}
}
By invThingie, do you mean the inventory GUI? gGuiname.Visible = false; will turn it off, added to the proper condition(s) of on_mouse_click (and/or possibly the eEventGUIMouseUp/Down conditions of on_event).
That 'use object' code should be fine. Does it not work, or haven't you tried it?
Yes it's checked.
By invThingie i mean the inventory object. The GUI works fine but when it comes to using the inventory objects I get nada. Once I've selected the inventory obj all it does is changing the cursor graphic and it stays that way... all clicks are responding as the 'normal' cursors
I use this code for the standard mouse clicks
if (button == eMouseLeft) {
String buffer = Game.GetLocationName(mouse.x, mouse.y);
if (StrComp(buffer, "") == 0) ProcessClick(mouse.x, mouse.y, eModeWalkto);
else ProcessClick(mouse.x, mouse.y, eModeLookat);
}
else if (button == eMouseRight) {
ProcessClick(mouse.x, mouse.y, eModeInteract);
}
You see, use inventory item on hotspot/object/character is triggered by eModeUseinv rather than eModeInteract, so you code becomes:
...
else if (button == eMouseRight) {
Ã,Â
if (player.ActiveInventory == null)
{
// normal clicks (no active inventory item)
ProcessClick(mouse.x, mouse.y, eModeInteract);
}
else
{
// active inventory clicks
ProcessClick(mouse.x, mouse.y, eModeUseinv);
}
Ã,Â
}
thanks I finally got it to work.
But how do I use an invobj with another?
"Inventory items" pane -> Select inventory item that you want to use something on -> "Interaction..." button -> Right-click "Use inventory on this item" -> "New Run Script action" (in older AGS versions "New action..." -> Select "Run script" -> "Edit script...") ->
// script for Inventory item: Use inventory on this item
// (This event is triggered by the "eModeUseinv" mouse mode)
if (player.ActiveInventory == iKey) { // if key used
// do stuff
}
else if (player.ActiveInventory == iPoster) { // if poster used
// do some other stuff
}
...and to trigger such active item on inv item events modify your on_mouse_click function code as follows:
if (button == eMouseRightInv) {
if (player.ActiveInventory == null)
{
player.ActiveInventory = inventory[ game.inv_activated ];
}
else
{
inventory[ game.inv_activated ].RunInteraction( eModeUseinv );
}
}
Should run interaction on right click (if there is an active inventory item to use).
Make sure Handle inventory clicks in script is checked.
See if it works.