I need help with single cursor interface

Started by adevin, Wed 02/11/2005 03:39:45

Previous topic - Next topic

adevin

Yes, I noticed the missing comma and fixed it. Using an inventory item on anything I've assigned an interaction to (main character, other characters, hotspots) will work just fine, it's just the normal "Interact hotspot" interactions that aren't working. I didn't change player characters.

Ashen

OK, been a while since I used 2.62, so I'm a bit rusty ....

Try changing:
Code: ags

else if (player.activeinv != 0) ProcessClick(mouse.x, mouse.y, MODE_USEINV);

to:
Code: ags
else if (player.activeinv > 0) ProcessClick(mouse.x, mouse.y, MODE_USEINV);


I think "no active inventory" is passed as -1, not 0 as I'd thought - so even with no active inv, it's not equal to 0. Needing it to be greater than 0 should solve it.
I know what you're thinking ... Don't think that.

adevin

#22
Alright, the on_mouse_click section of the script now looks like this:

Code: ags
function on_mouse_click(int button) {
if (button == LEFT) {
Ã,  GetLocationName(mouse.x, mouse.y, buffer);
Ã,  if (StrComp("", buffer) == 0) ProcessClick(mouse.x, mouse.y, MODE_WALK);
else if (player.activeinv > 0) ProcessClick(mouse.x, mouse.y, MODE_USEINV);
Ã,  else ProcessClick(mouse.x, mouse.y, MODE_USE);
}


I think I've followed everything you've said correctly. If not, I thought posting this might help. At this point, for some reason, a right click will not open the Inventory GUI anymore, in addition to the left clicks on hotspots not resulting in the assigned "Interact hotspot" interactions. Sorry for all this trouble, but I'm very confused.

EDIT: Ah, I was mistaken, the normal "Interact hotspot" interactions are now working as they were before, but the Inventory GUI won't open with the right click.

Ashen

OK, one problem down, one to go ...

Can you show the right-click part of your on_mouse_click?
I know what you're thinking ... Don't think that.

adevin

There's nothing else under on_mouse_click at all, besides the stuff I posted.

Ashen

Well then, how was the inventory being called, when it worked?
I'd have though the easiest way would've been a if (button == RIGHT) condition in on_mouse_click - could you have accidentally deleted it or are you using some other method? (In which case - can you show that code?)
I know what you're thinking ... Don't think that.

adevin

No, I think I must have deleted it. What would the code for that be?

Ashen

Code: ags

function on_mouse_click(int button) {
  if (button == LEFT) {
    GetLocationName(mouse.x, mouse.y, buffer);
    if (StrComp("", buffer) == 0) ProcessClick(mouse.x, mouse.y, MODE_WALK);
    else if (player.activeinv > 0) ProcessClick(mouse.x, mouse.y, MODE_USEINV);
    else ProcessClick(mouse.x, mouse.y, MODE_USE);
  }
  else if (button == RIGHT) { // 
    show_inventory_window();
  }
}


That should do it, or GUIOn(INVENTORY); (or whatever your Inventory GUI is called) would do, if you're not worried about changing the cursor graphic (show_inventory_window() changes the Use cursor from a hand to an arrow). The default script also has a condition to stop it doing anything if the game is paused - you might want to include that.
Code: ags

function on_mouse_click(int button) {
  if (IsGamePaused() == 1) {
    // Game paused, do nothing
  }
  else if (button == LEFT) { // NOTE: now 'else if', not just 'if'
    //Blah blah blah
// Etc - rest of function
}
I know what you're thinking ... Don't think that.

adevin

Great, everything's working now, thanks alot for all your help.

adevin

I'm having a slight problem with inventory items, and I suspect it has something to do with the way I have right and left clicks set up. When I take an item out of the inventory, and the cursor becomes the inventory image, I can't get the cursor to change back until I've used the item on the correct hotspot. This means that my normal "Interact hotspot" functions will not work, because the cursor is stuck in the use inventory mode. What can I do?

Ashen

Depends on how you want it to work.

You could set up unhandled_event so that if you try to use an item on a hotspot, character or object that doesn't have an interaction set up, it either clears the active item (sets no item as active), or runs the default 'Interact' interaction.You'll also have to add a command to the 'Use inventory on hotspot' interaction - if there's any inventory interaction set up, AFAIK unhandled_event won't be run, even when you use a different item.
You could also use unhandled_event to make it so clicking on nothing clears the active item.
(Both of these can be done without unhandled_event - using it just saves you from having to write the same few lines out over and over. Look it up in the manual or a forum search for more details.)

However, it might be simpler to alter the right click function slightly, so that it clears the active inventory item if there is one, and opens the inventory if there isn't, e.g.:
Code: ags

  else if (button == RIGHT) { //
    if (player.activeinv > 0) SetActiveInventory(-1);
    else show_inventory_window();
  }
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk