One last, quick question: when I have an inventory icon selected as the cursor, I need it to change (either to another image or to ananimation view, whatever is easier) over a hotspot or an object.
It should be something global, that icon should change over any object or hotspot in any room.
I know that it's probably shemfully easy, but I really can't find it anywhere.
Using the GetLocationType function you don't have to write a code for every hotspot in the game and you get
the cursor change also above objects and characters ( tou can modify it to change only on hotspots or objects,
change it to TALK when above characters etc)
Let's say your cursors are:
0 WALK
1 LOOK
2 USE
3 TALK
4 TAKE // NOT USED
5 CHANGED WALK
6 CHANGED LOOK
7 CHANGED USE
8 CHANGED TALK
9 WAIT
Just put the following code in the GLOBAL SCRIPT'S REPEATEDLY EXECUTE function
GetLocationName(mouse.x,mouse.y,name); // Get the name of what's under the cursor
if (StrComp(name,"")==0) SetDefaultCursor(); // if blank ( or hotspot with no name
//'used for CHAR STANDS ON HOTSPOT') do nothing
else {
if (GetCursorMode()==0) { //if cursor is WALK
if (GetLocationType(mouse.x,mouse.y)>0) SetMouseCursor(5); // change cursor to CHANGED WALK
else SetDefaultCursor(); } // change back to WALK
if (GetCursorMode()==1) { // if cursor is LOOK
if (GetLocationType(mouse.x,mouse.y)>0) SetMouseCursor(6); // change cursor to CHANGED LOOK
else SetDefaultCursor(); } // change back to LOOK
if (GetCursorMode()==2) { // if cursor is USE
if (GetLocationType(mouse.x,mouse.y)>0) SetMouseCursor(7); // change to CHANGED USE
else SetDefaultCursor(); } // change back to USE
if (GetCursorMode()==3) { // if cursor is TALK
if (GetLocationType(mouse.x,mouse.y)>0) SetMouseCursor(8); // Change to CHANGED TALK
else SetDefaultCursor(); } // change back to TALK
}
Once again, someone replies to something while I'm typing up my reply. And once again, I'll post it anyway:
You need to use the repeatedly_execute function, in the global script. Something like:
int changed;
function repeatedly_execute() {
// put anything you want to happen every game cycle here
if (GetCursorMode () == 4) { // if you're in 'Use Inventory' mode
if (GetLocationType (mouse.x, mouse.y) != 0 && changed == 0) { // Mouse is over something other than a GUI, and hasn't been changed
ChangeCursorGraphic (MODE_USEINV, NEWGRAPHIC); // Replace NEWGRAPHIC with the sprite slot of the graphic you want
changed = 1; // Cursor has been changed
}
else if (GetLocationType (mouse.x, mouse.y) == 0 && changed == 1) { // Mouse is over nothing, but cursor is changed
ChangeCursorGraphic (MODE_USEINV, GetInvGraphic (player.activeinv)); // Change cursor back
changed = 0; // Cursor has been changed back
}
}
}
This'll change the cursor to the same image, no matter what item is being used. If you want a different image for each item, it's a little more complicated. The easiest way would probably be to give each item an 'Alternate Cursor' property, in the editor, and use ChangeCursorGraphic (MODE_USEINV, GetInvProperty (player.avtiveinv, "Alternate Cursor"); to change it.
If you want an animated view, set it up in an unused cursor mode, and use SetMouseCursor(mode); to change it, and SetDefaultCursor() to change it back.
Candle's way is good as well (although it doesn't deal with 'Use Inv' mode), since it's a more general 'Change cursor over thing' script than mine . It could be trimmed down a little, though:
if (GetLocationType (mouse.x, mouse.y) != 0) {
if (GetCursorMode()==0) SetMouseCursor(5); // if WALK change cursor to CHANGED WALK
else if (GetCursorMode()==1) SetMouseCursor(6); // if LOOK change cursor to CHANGED LOOK
else if (GetCursorMode()==2) SetMouseCursor(7); // if USE change to CHANGED USE
else if (GetCursorMode()==3) SetMouseCursor(8 ); // if TALK change to CHANGED TALK
}
else SetDefaultCursor(); } // change back to default