Hey there!
Is it possible to give the "interact" cursormode another mode in addition to interacting?
Think "Mixed-Up Fairy Tales" by Sierra. You had one "interact" cursor, and also whereever you clicked, your character would move.
Look for the on_mouse_click function in GlobalScript.asc.
In there is the eMouseLeft section that calls ProcessClick(mouse.x, mouse.y, mouse.Mode);
Replace that line with this:
if (mouse.Mode == eModeInteract && GetLocationType(mouse.x, mouse.y) == eLocationNothing) ProcessClick(mouse.x, mouse.y, eModeWalkto);
else ProcessClick(mouse.x, mouse.y, mouse.Mode);
That should do it.
Paying this one forward because I asked a similar question recently.
else if (button == eMouseLeft) // Left click
{
if(GetLocationType(mouse.x, mouse.y) == eLocationNothing) // If not over anything clickable, walk
{
ProcessClick(mouse.x, mouse.y, eModeWalkto);
}
else
{
if(mouse.Mode == eModeUseinv)
{
ProcessClick(mouse.x, mouse.y, eModeUseinv); // Use inventory item
}
else
{
ProcessClick(mouse.x,mouse.y, eModeInteract); // Interact with object/char/hotspot
}
}
}
else if (button == eMouseRight) // right-click, so look or cancel inv. item
{
if(mouse.Mode == eModeUseinv)
{
mouse.Mode = eModeInteract;
}
else
{
ProcessClick(mouse.x,mouse.y, eModeLookat);
}
}
The key to this whole thing (and Khris's as well) is GetLocationType(mouse.x, mouse.y) which gets called when you click. It looks at the coordinate provided and returns one of these: eLocationCharacter, eLocationHotspot, eLocationObject, eLocationNothing. The code above (provided to me by Snarky originally) also includes item usage, another feature you probably want with your UI.
KBlaney:
That code is for a kinda-sorta two-button interface, not multiple cursor modes. If that's what Dhelayan wants, then fine, but you should've mentioned that you aren't really answering his question but suggesting an entirely different UI.
Quote from: Khris on Tue 05/03/2013 00:59:40
Look for the on_mouse_click function in GlobalScript.asc.
In there is the eMouseLeft section that calls ProcessClick(mouse.x, mouse.y, mouse.Mode);
Replace that line with this:
if (mouse.Mode == eModeInteract && GetLocationType(mouse.x, mouse.y) == eLocationNothing) ProcessClick(mouse.x, mouse.y, eModeWalkto);
else ProcessClick(mouse.x, mouse.y, mouse.Mode);
That should do it.
Wooohoo! That did it :D thankies so much! Slowly getting the hang of it all XD
Quote from: Khris on Tue 05/03/2013 10:09:42
That code is for a kinda-sorta two-button interface
"Kinda-sorta" how? It's exactly a two-button interface, n'est-ce pas?
Yes, but using that code in combination with the default interface currently used by Dhelayan will give awkward results.
Example: if eModeLookat is the active mode and I click on something, the player will interact with it. Thus I wanted to discourage Dhelayan from trying the code as-is.
If somebody is looking to build a two-button interface and has already disabled all cursor modes except eModeInteract and eModeUseinv, that code will work fine of course.
I was looking to provide an example of how GetLocationType can be used in conjunction with cursor modes to set up conditionals. Maybe a bad assumption on my part, but I didn't expect him to copy and paste code into his project without modifying it or understanding it at all.
But yes, in that example code left click does all the walking and interacting but right click does all the looking.