Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Matti on Tue 17/10/2006 21:04:14

Title: Cursormodes in Inventory (SOLVED)
Post by: Matti on Tue 17/10/2006 21:04:14
I wanna make an inventory where I still can change the cursormode with a right-click, instead of clicking on a symbol for that. I don't know where to put the script for that and what exactly I have to script.

And the inventory is supposed to pop up at a specific y-coordinate of the cursor (no problem), but should disappear when the cursor is somewhere else again, without clicking on a OK-Button or something.
Title: Re: Cursormodes in Inventory
Post by: Mel_O_Die on Tue 17/10/2006 21:31:31
Hi!

On your ags program click on "script" and "on_mouse_click" to open and reach directly the good place in the code

there is my code for doing that


if (button == eMouseLeftInv) { // left click on inventory item

Ã,  Ã,  Ã,  if (mouse.Mode == eModeInteract) { // select inventory item on eModeInteract:

player.ActiveInventory = inventory[ game.inv_activated ];

Ã,  Ã,  Ã,  }

Ã,  Ã,  Ã, else { // if your cursor isn't in interact mode, it will run the action wanted by the cursor selected
Ã,  Ã,  Ã,  Ã,  Ã, inventory[ game.inv_activated ].RunInteraction( mouse.Mode );
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  }

}

else if (button == eMouseRightInv){ // right click

mouse.SelectNextMode(); //select next cursor mode
}



I hope there is no mistakes :D

don't hesitate for questions about that!
      
Title: Re: Cursormodes in Inventory
Post by: Matti on Wed 18/10/2006 13:40:35
Thanks,
but it's not working properly yet.

First of all the cursor only changes when it's over an item, but it should change wherever it is in the inventory.

And the weird thing is, when I right-click (over an item), it only switches between walk- and interact-mode. When I left-click, it cycles through walk-mode, look-mode and the item. When I then right-click again, the talk-mode is added.

So the main problem is that the cursormode also changes with a left-click.

Another problem is that the cursor changes into the pointer-view (arrow) when I make the Inventory pop up at a specific y-coordinate.
Title: Re: Cursormodes in Inventory
Post by: Theeph on Fri 20/10/2006 13:36:19
The fact that your cursor is not changing except when over an item suggests that the mouse button code is only being called as an onClick event for items.

It depends how you're coding it... I've had similar problems that I've resolved with a:


if(gInventory.visible == true){
         // do stuff
}


in the repeatedly_execute of the global script. Don't know if that's especially elegant but I found it was the only way I could think of at the time.

Anyway I'd also check the script for your gui interaction to make sure you have a final "else" statement for when the mouse clicks and it's not over any button, and then drop Mel_O_Die's code in there as well:


if (button == eMouseRightInv){ // right click

mouse.SelectNextMode(); //select next cursor mode
}

     
Title: Re: Cursormodes in Inventory
Post by: Matti on Sat 21/10/2006 17:28:55
When I put the script in the repeatedly execute section the word "button" isn't recognized. But it doesn't matter.
And however, the other problems are fixed by now.
Thanks.