I need to change mouse cursor to LookAt when it pass over a hotspot or object
I do this script for every hotspot:
if (Mouse.Mode != 4) {
mouse.SaveCursorUntilItLeaves();
mouse.Mode = eModeLookat;
}
but i think it's possibile to do this in global script only one time and not for every hotspot
i found this
thread
(http://www.adventuregamestudio.co.uk/yabb/index.php?topic=30314.0) but i think there is a easy way (hoping so :P)
You could put in the global script's repeatedly_execute function:
Hotspot* hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
if ((hat != null) && (hat != hotspot[0]) && (mouse.Mode != eModeLookat)) {
mouse.SaveCursorUntilItLeaves();
mouse.Mode = eModeLookat;
}
That way any time the mouse is over a hotspot other than hotspot 0 (the "no hotspot" hotspot ;)), it will run the code to set the mouse mode.
Alternatively, one can use " if GetLocationType(mouse.x, mouse.y) == eLocationHotspot)".
Quote from: monkey_05_06 on Sat 19/01/2008 21:35:53
You could put in the global script's repeatedly_execute function:
Hotspot* hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
if ((hat != null) && (hat != hotspot[0]) && (mouse.Mode != eModeLookat)) {
mouse.SaveCursorUntilItLeaves();
mouse.Mode = eModeLookat;
}
That way any time the mouse is over a hotspot other than hotspot 0 (the "no hotspot" hotspot ;)), it will run the code to set the mouse mode.
thank for your quick and useful answer
it works, but if i click second mouse button it returns to LookAt and i cant interact with the object :(
Quote from: KhrisMUC on Sat 19/01/2008 21:40:43
Alternatively, one can use " if GetLocationType(mouse.x, mouse.y) == eLocationHotspot)".
thank you too :)
but same problem with right mouse button :(
Remove the code that cycles the mouse buttons (if you can't find it in the global script you're a tool).
Quote from: Crazy on Sat 19/01/2008 22:41:46
Remove the code that cycles the mouse buttons (if you can't find it in the global script you're a tool).
thanks, but don't help
i using this script (thanks to KhrisMUC)
int lt=GetLocationType(mouse.x, mouse.y);
if (lt==eLocationNothing) {
mouse.DisableMode(eModeLookat);
mouse.DisableMode(eModeInteract);
mouse.DisableMode(eModeTalkto);
}
else {
mouse.EnableMode(eModeLookat);
mouse.EnableMode(eModeInteract);
if (lt==eLocationCharacter) mouse.EnableMode(eModeTalkto);
else mouse.DisableMode(eModeTalkto);
}
when mouse isn't over an hotspot, object or char, it simple disable all cursors expect walkto
but when it pass over an object on the inventory i can't change cursor so i can't interact with it.
i tried this:
if (mouse.y > 200) {
mouse.EnableMode(eModeLookat);
mouse.EnableMode(eModeInteract);
}
cause inventory starts at y position = 200 pixel
but it works only if mouse is at y=200 not y>200
any suggest
LocationType lt=GetLocationType(mouse.x, mouse.y); // changed 'int' to 'LocationType' since that's what actually what GetLocationType returns
// not that it makes a difference
if (lt==eLocationNothing) {
mouse.DisableMode(eModeLookat);
mouse.DisableMode(eModeInteract);
mouse.DisableMode(eModeTalkto);
if (InventoryItem.GetAtScreenXY(mouse.x, mouse.y) != null) {
mouse.EnableMode(eModeInteract);
mouse.DisableMode(eModeWalkto);
}
else mouse.EnableMode(eModeWalkto);
}
else {
mouse.EnableMode(eModeLookat);
mouse.EnableMode(eModeInteract);
if (lt==eLocationCharacter) mouse.EnableMode(eModeTalkto);
else mouse.DisableMode(eModeTalkto);
}
Use InventoryItem.GetAtScreenXY. There's really no difference between using Hotspot.GetAtScreenXY and GetLocationType (other than return value of course), but GetLocationType can't be used for InventoryItems or GUIs while their respective GetAtScreenXY functions can.
BTW Crazy, that wouldn't actually help the problem as he still wants the cursor to cycle in certain cases. Further, there's no reason to insult anyone simply because they ask for help.
Quote from: monkey_05_06 on Thu 24/01/2008 18:33:33
LocationType lt=GetLocationType(mouse.x, mouse.y); // changed 'int' to 'LocationType' since that's what actually what GetLocationType returns
// not that it makes a difference
if (lt==eLocationNothing) {
mouse.DisableMode(eModeLookat);
mouse.DisableMode(eModeInteract);
mouse.DisableMode(eModeTalkto);
if (InventoryItem.GetAtScreenXY(mouse.x, mouse.y) != null) {
mouse.EnableMode(eModeInteract);
mouse.DisableMode(eModeWalkto);
}
else mouse.EnableMode(eModeWalkto);
}
else {
mouse.EnableMode(eModeLookat);
mouse.EnableMode(eModeInteract);
if (lt==eLocationCharacter) mouse.EnableMode(eModeTalkto);
else mouse.DisableMode(eModeTalkto);
}
Use InventoryItem.GetAtScreenXY. There's really no difference between using Hotspot.GetAtScreenXY and GetLocationType (other than return value of course), but GetLocationType can't be used for InventoryItems or GUIs while their respective GetAtScreenXY functions can.
BTW Crazy, that wouldn't actually help the problem as he still wants the cursor to cycle in certain cases. Further, there's no reason to insult anyone simply because they ask for help.
yepppp it works, but in the inventory cursor change to interact, no way to change it to lookat (adding mouse.EnableMode(eModeLookat); seems not working...)
1. Don't quote the post directly above yours.
2. Show us the code you've used.
this is the code:
LocationType lt=GetLocationType(mouse.x, mouse.y); // changed 'int' to 'LocationType' since that's what actually what GetLocationType returns
// not that it makes a difference
if (lt==eLocationNothing) {
mouse.DisableMode(eModeLookat);
mouse.DisableMode(eModeInteract);
mouse.DisableMode(eModeTalkto);
if (InventoryItem.GetAtScreenXY(mouse.x, mouse.y) != null) {
mouse.EnableMode(eModeInteract);
mouse.EnableMode(eModeLookat); //<----THIS SEEMS NOT TO WORK
mouse.DisableMode(eModeWalkto);
}
else mouse.EnableMode(eModeWalkto);
}
else {
mouse.EnableMode(eModeLookat);
mouse.EnableMode(eModeInteract);
if (lt==eLocationCharacter) mouse.EnableMode(eModeTalkto);
else mouse.DisableMode(eModeTalkto);
}
the line that don't works is where there is "<----THIS SEEMS NOT TO WORK"
I don't see why eModeLookat wouldn't be working but just as a matter of interest, does it make a difference if you explicitly set the cursor to eModeInteract or eModeLookat before disabling eModeWalkto?
// ...
mouse.EnableMode(eModeInteract);
mouse.EnableMode(eModeLookat);
mouse.Mode = eModeLookat;
mouse.DisableMode(eModeWalkto);
// ...
Also, I thought of something about what I said regarding GetLocationType/Hotspot.GetAtScreenXY: GetLocationType also will return the value of whatever is shown on-screen whereas Hotspot.GetAtScreenXY ignores what is shown and just checks which hotspot is at the given point. What this essentially means is that if you want to check what is shown at the given (x, y) GetLocationType will work, but if you want to do something with the hotspot at the given point, it would be easier just to use Hotspot.GetAtScreenXY since you'll need to do this anyway (of course if you want to do something with the Hotspot only if it is shown you would need both).
I think that problem is that when we are in the inventory items piece of code the cicle cursor don't work, and i can't understand why...
The cycle-cursor command is in the eMouseRight block. However, if the mouse is over an inv item, on_mouse_click is called with eMouseRightInv.
One solution is to use:
else if (button == eMouseRight || button == eMouseRightInv) {
...