i'm using a lec gui which i've modified quite a bit... thing is, i want to use the right mouse button to look at an inventory item and the left button to use the item with something else... the looking works, but the using doesn't... dunno why. i'll post most of the global script, cuz i'm not sure whether the error is in the on_mouse_click function...
// main global script file
function repeatedly_execute() {
// put anything you want to happen every game cycle here
// This is an adaptation made by me of the WHOLE LEC GUI code.
// In a LEC game this should be put in the global REP.EXEC.
string buffer; string madetext; int cur_mode;
// Initialize the status line
StrCopy (madetext, "");
cur_mode=GetCursorMode();
if (cur_mode == MODE_USE) {
StrCat(madetext,"Use ");
GetInvName (player.activeinv, buffer);
StrCat(madetext,buffer);
StrCat(madetext," on ");
}
// Find out what's under the cursor, and add it to the status line
GetLocationName(mouse.x,mouse.y,buffer);
StrCat(madetext,buffer);
SetLabelText ( 1, 3, madetext);
}
function on_mouse_click(int button) {
// called when a mouse button is clicked. button is either LEFT or RIGHT
if (IsGamePaused() == 1) {
// Game is paused, so do nothing (ie. don't allow mouse click)
}
else if (button==LEFT) {
      if (GetLocationType(mouse.x,mouse.y)==2)
      {SetCursorMode (MODE_TALK);
      ProcessClick(mouse.x,mouse.y,MODE_TALK);}
      else if ((GetLocationType(mouse.x,mouse.y)==1)||(GetLocationType(mouse.x,mouse.y)==3))
      {SetCursorMode (MODE_USE);
      ProcessClick(mouse.x,mouse.y,MODE_USE);}
      else {SetCursorMode(MODE_WALK);
      ProcessClick(mouse.x, mouse.y,MODE_WALK);
      }
}
else if (button==RIGHT)
   {FaceLocation (GetPlayerCharacter(),mouse.x+GetViewportX(),mouse.y+GetViewportY()); // character looks at the hotspot
SetCursorMode(MODE_LOOK);
ProcessClick(mouse.x, mouse.y,MODE_LOOK );
}
else if (button == LEFTINV) {
   RunInventoryInteraction (game.inv_activated, MODE_USE);
   }
else if (button == RIGHTINV) {
   RunInventoryInteraction (game.inv_activated, MODE_LOOK);
   }
SetCursorMode(MODE_WALK);
}
function interface_click(int interface, int button) {
if (interface == 1) { //The LEC interface
if ((button == 0) & (game.top_inv_item < game.num_inv_items - 8))
game.top_inv_item = game.top_inv_item + 4;
if ((button == 1) & (game.top_inv_item > 0))
game.top_inv_item = game.top_inv_item - 4;
if (button == 4) // save game
SaveGameDialog();
else if (button == 5) // load game
RestoreGameDialog();
else if (button == 6) // quit
QuitGame(1);
else if (button == 7) // about
Display("blah");
}
}
what bugs me is that i have the same problem with "handle inv clicks in script" turned off: looking works, but using doesn't.
in order to select an inventory item for using it on something else, i think you should replace:
RunInventoryInteraction....
with:
SetActiveInventory(GetInvAt(mouse.x,mouse.y));
in the LEFTINV part of your mouseclick function
that didn't work :(
i looked in the manual and SetActiveInventory only makes the item active but it doesn't do what i want it to do: i want the cursor to change to the image of the item and i want to use the item with whatever i click on next... pretty simple huh? too bad i can't find a way to do it, and i've searched the manual and several tutorials.... if i only knew what i'm doing wrong... >:(
in the general settings tab... the first tabbed window, there is a selection that says use inventory as cursor.
it says "don't use inv items as cursors" and it's not checked....
ok, i'm gonna post a link to this on the tech forum and, if noone can help me, i'm gonna let it die :(
You shouldn't really have done the double post...
Have you set the cursor mode to MODE_USEINV?
Instead of:
else if (button == LEFTINV) {
RunInventoryInteraction (game.inv_activated, MODE_USE);
}
you want:
else if (button == LEFTINV) {
SetActiveInventory (game.inv_activated);
return;
}
The reason it didn't work when you tried SetActiveInv is because you have a SetCursorMode(MODE_WALK); just underneath which was resetting it back.