Cursormodes in Inventory (SOLVED)

Started by Matti, Tue 17/10/2006 21:04:14

Previous topic - Next topic

Matti

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.

Mel_O_Die

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

Code: ags

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!
      
----( )----
Click to see "In Production" Topic!
[/color][/b][/url]

Matti

#2
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.

Theeph

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:

Code: ags

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:

Code: ags

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

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

     

Matti

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.

SMF spam blocked by CleanTalk