I am designing an inventory GUI that is constantly visible on the bottom of the screen (resembling the one from "The Uncertainty Machine" [great game]).
I tick "handle inventory clicks in script" and I use to following code in on_mouse_click function :
if (button == LEFTINV) {
RunInventoryInteraction (game.inv_activated, MODE_USE);
}
if (button == RIGHTINV) {
RunInventoryInteraction (game.inv_activated, MODE_LOOK);
}
The RIGHTINV part works normally, but I cannot make the cursor pick up the item with the LEFTINV.
I actually take no responce.
Putting MODE_USEINV instead of MODE_USE only interacts with the item and doesn't pick it up.
Any suggestions? I'm a begginer.
Thanks
Maybe you've got this, and I'm just talking crap, but using the
if (button == LEFTINV) {
RunInventoryInteraction (game.inv_activated, MODE_USE);
}
version, have you got the inventory items USE interaction set to make that item the active item. I.E. Inventory Item 2 would have the USE interaction
SetActiveInventory(2);
instead using RunInventoryInteraction, you could try the following:
Set that item as the active item .Dont know if there is a function like SetActiveInv or so. If there isnt, you can use a game. variable, dont know the exact name, but it is something like character[GetPlayerCharacter()].activeinv=GetInvAt(mouse.x,mouse.y);
and then set cursor mode 4:
SetCursorMode(4);
Sorry for not being very precise : / (i dont have ags here), but i hope this helps.
Thanks for your help. Your suggestions have been very useful.
I have managed however to solve the problem (actually go around it) with the following code:
In the repeatedly_execute function I put:
if (mouse.y>184) { // this checks if the cursor is over the inventory GUI
if (GetGlobalInt(499)==0) { // this ensures that the mode change happens only once
SetGlobalInt (499, 1);
SetCursorMode (MODE_USE);
SetMouseCursor (6);
}
}
if ((mouse.y<184) && (GetCursorMode()!=MODE_USEINV) && (GetGlobalInt(499)==1)) { // this reverts the cursor back to walk mode after leaving the inventory unless an item is selected
SetCursorMode (MODE_WALK);
SetGlobalInt(499, 0);
}
This goes in the on_mouse_click function:
if (button == RIGHTINV) {
RunInventoryInteraction (game.inv_activated, MODE_LOOK);
}
The script works fine, but the "Handle inventory clicks in script" must NOT be ticked.
I know this solution is a bit akward but it works.
I wait for your opinions.
Quote from: Skio on Thu 29/04/2004 21:22:05The script works fine, but the "Handle inventory clicks in script" must NOT be ticked.
I see your approach but the only problem is that ...
if (button == RIGHTINV) {
RunInventoryInteraction (game.inv_activated, MODE_LOOK);
}
... doesn't work unless the
Handle inventory clicks in script option is ticked. That's because the RIGHTINV and LEFTINV can only occur if it's turned on. But the look at inv item interaction will still work as if handle inv clicks is off AGS uses its internal mechanism (which runs look interaction on right click). Basically, it means you can remove these lines from the on_mouse_click() and it will still work.
Another possibility, as guys already said, would be to leave it ticked but make a use of that SetActiveInventory() function, for example in the original code:
with Handle inventory clicks in script ticked:
on_mouse_click:if (button == LEFTINV) {
SetActiveInventory(game.inv_activated);}
if (button == RIGHTINV) {
RunInventoryInteraction (game.inv_activated, MODE_LOOK);
}
Hope that helps :)
You were right! The RIGHTINV part of the script is obsolete. Even without it however, I get the desired effect - looking at the object by right-clicking on it. How this works, don't ask...!!!
I still have the "handle inventory..." unticked and I use the aforementioned code.
It works.