(Resolved!) Changing Mouse Cursor Through Scripting

Started by gamemaster468, Fri 08/07/2016 04:42:01

Previous topic - Next topic

gamemaster468

So I'm not sure if this question falls under the beginners, or advanced category. I've only recently started getting back into this program, so I'm a bit of a noob at AGS. I can't imagine this question having a very complicated answer, so here goes. :P

The game I'm working on only uses one mouse cursor, as apposed to multiple cursors like most AGS games use. So the ability to switch between cursors has been disabled. Thing is, this creates a bit of a problem in regards to inventory items. While the game still switches to the inventory item that I want to use when I click on it, there is still no means of switching back to the default cursor, creating an issue where your cursor is stuck on which ever item you selected. I want to know if there's some command I'm missing that I could use to fix this problem, where after the player uses the inventory item on something, it switches the cursor back to the default cursor. That's pretty much it. Hope someone out there has a solution. :)
-gamemaster468

Slasher

#1
An easy way would be to have a button that takes away the inv cursor and returns to your default

A game i'm working only only used one mode (interact) which is used for walk, interact, look, talk and use inv...

I have a gui button that when clicked changes the cursor back to interact after inventory item has been selected.

Code: ags

function Button19_OnClick(GUIControl *control, MouseButton button) // a button labelled 'Return Item'
{
  player.ActiveInventory=null; // or use character script name
  mouse.Mode=eModeInteract; // optional: cursor returns to this
}


And just add script after you use on an object/character etc depends...

It depends on how your game actually works and i am sure there are other methods somewhat more modern...

hope this helps





dayowlron

In the code that processes each inventory item just add a line to set the mouse back to whatever default cursor you want.
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

Khris

If the interaction is successful and the player loses the item, AGS should switch to the next active cursor mode anyway. (removing the item from the player's inventory means it can no longer be set as player.ActiveInventory, which makes AGS move off of eMouseUseinv, iirc).

Game designers commonly set up the right mouse button to deselect the active item, all you need to do to implement that is: player.ActiveInventory = null; in on_mouse_click / eMouseRight.

Btw, moving back to the default cursor after an unsuccessful interaction is not recommended; this will annoy most users (me at least ;))

dayowlron

Of course you would want to do it after the interaction was successful, but all I was saying that setting player.ActiveInventory = null would do the same thing as setting the mouse cursor back to the default cursor.
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

gamemaster468

mouse.Mode=eModeInteract; // optional: cursor returns to this

That's what I needed. I knew there was some super simple scripting command I was missing. :P Thanks for the help. :)
-gamemaster468

Khris

Just a note:
If you put that in dozens of objects and hotspot interactions and should decide to use some other cursor (or change the controls in some other way) at some point in the future, you'll have to replace all of those lines in multiple scripts.
Always use the route that is least likely to cause problems later on, regardless of how far-fetched that might seem. If you want to deselect the inventory item, you should actually deselect it, not do something else.

gamemaster468

"If you put that in dozens of objects and hotspot interactions and should decide to use some other cursor (or change the controls in some other way)"

Except I don't really know how to do that. Programming isn't really my expertise. I'm more of an animation, designer, and story writer kinda guy. I can do the basic AGS commands just fine, but I don't really know how to do the actual SCRIPTING scripting, if you get what I mean.
-gamemaster468

Slasher

Hi

I understand full well what Khris means so it's important that once you commit to this you stick with it because it can be a devil to change tons of stuff, so be sure it's what you want.

SMF spam blocked by CleanTalk