(SOLVED) change to pointer mode over Inventory window

Started by Nixxon, Tue 20/10/2015 12:12:10

Previous topic - Next topic

MiteWiseacreLives!

Quote from: Nixxon on Wed 28/10/2015 03:30:09
Quote from: MiteWiseacreLives! on Wed 28/10/2015 02:16:52
Yes you can have if statement inside of another.
Not to be insulting, but are you actually reading my replies?
The code goes where I indicated, inside of the (overmenubar == true) block of code, you want to intercept the mouse.Mode = old_mouse_mode
If this is still not clicking for you I can get on my computer and type up the code for you later.

No insult taken at all, I did try the code provided 5-6 different which ways before resorting to the boards, I always do.

I'll give it a go when I get home, thanks again for the patience and assistance.

ok so if your actually trying to learn here...

Code: ags

function repeatedly_execute() {
  
  // Put here anything you want to happen every game cycle, even when
  // the game is paused. This will not run when the game is blocked
  // inside a command like a blocking Walk()
  if (GUI.GetAtScreenXY(mouse.x, mouse.y) == ginvwindow) //every game cycle we check if the mouse is over the inventory window
  {
    if (overmenubar == false) // checks if we are already over the inventory window, if so skip this code we only need do it once.
    {
      old_mouse_mode = mouse.Mode;  //store the current mouse mode
      mouse.Mode = eModeInteract; // change mode to the interact/pointer cursor
      overmenubar = true; // set to true so this block of code doesn't run endlessly
      mouse.DisableMode(eModeTalkto);   // start disabling all the mouse modes so player doesn't cycle through them
      //etc here insert the rest of the mouse.DisableMode(eMode...); lines you need dependant on the mouse modes in your game.
    }
  }
  else  // if the mouse is not over the inventory window
  {
    if (overmenubar == true) // if this is true, the mouse must have just been over the inventory window
    {
      // mouse.Mode = eModeInteract; <----- remove this line! it will simply change cursor to the interact mode!!
      overmenubar = false;
      if (mouse.Mode != eModeUseinv)  { //so if the mouse mode is anything other than Use Inventory Mode
        mouse.Mode = old_mouse_mode;  // set it to the mouse mode the player had before entering the area of the inventory window,
      }
      // otherwise it will leave the cursor as a selected inventory item.
      mouse.EnableMode(eModeLookat);     // now Look At is available to the player again.
      //etc... insert all the mouse modes you want to re-enable like: mouse.EnableMode(eModeInteract);
    }    
  }
}


Study this and you should understand what we are coding here and be able to carry on from this point (not that you shouldn't continue to ask for help if needed...)
Remember that repeatedly_execute runs 40 times / second, unless the game is paused.

Nixxon

#21
Wow, haven't tried this yet, but that's truly amazing thank you.

I will leave the eModeInteract line of code, as for some reason the pointer doesn't seem to select inventory items.


EDIT, still no cigar :( Whilst the code doesn't run any errors, the cursor still returns to the previous mode when the cursor leaves the ginvwindow GUI. Ultra poop.

EDIT 2 - NEVERMIND, I see why I had to remove the Modeinteract in the second part of the code!!! Works brilliantly now. Thank you so much.

SMF spam blocked by CleanTalk