Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Stapper

#21
I've been using the single click cursor script from hedgefield (link) which works very nicely.
I would like to add the feature of closing the inventory automatically upon selecting an item. I know I have to use "gInventory.Visible = false;" but I have no idea where to place it. I've tried certain lines but none of them worked. Is it possible to do this within this script?

Here is the script for reference:
Code: ags
//MOUSE CLICKS
function on_mouse_click(MouseButton button) {
  //Walk/Talk/Interact:
  if ((button == eMouseLeft && SC_SwapLeftRight == false) || (button == eMouseRight && SC_SwapLeftRight == true)) {
    if ((GetLocationType(mouse.x, mouse.y) == eLocationHotspot) || (GetLocationType(mouse.x, mouse.y) == eLocationObject)) {
      if (mouse.Mode == eModeUseinv) ProcessClick(mouse.x,mouse.y, mouse.Mode);
      else ProcessClick(mouse.x, mouse.y, eModeInteract);
    }
    else if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter) {
      if (mouse.Mode == eModeUseinv) ProcessClick(mouse.x, mouse.y, mouse.Mode);
      else ProcessClick(mouse.x, mouse.y, eModeTalkto);
    }
    else ProcessClick(mouse.x, mouse.y, eModeWalkto);
  }
  //LookAt:
  else if ((button == eMouseRight && SC_SwapLeftRight == false) || (button == eMouseLeft && SC_SwapLeftRight == true)) {
    if (mouse.Mode == eModeUseinv) {
      player.ActiveInventory = null;
      mouse.Mode = eModePointer;
    }
    else if ((GetLocationType(mouse.x, mouse.y) == eLocationHotspot) || (GetLocationType(mouse.x, mouse.y) == eLocationCharacter) || (GetLocationType(mouse.x, mouse.y) == eLocationObject)) {
      ProcessClick(mouse.x, mouse.y, eModeLookat);
    }
  }
  //Inventory select/combine:
  if (SC_CustomInvClicks == true) {
    if ((button == eMouseLeftInv && SC_SwapLeftRight == false) || (button == eMouseRightInv && SC_SwapLeftRight == true)) {
      if (inventory[game.inv_activated].IsInteractionAvailable(eModeUseinv) == 1 && mouse.Mode == eModeUseinv) {
        inventory[game.inv_activated].RunInteraction(eModeUseinv);
      }
      else if (inventory[game.inv_activated].IsInteractionAvailable(eModeInteract) == 1) inventory[game.inv_activated].RunInteraction(eModeInteract);
      else player.ActiveInventory = inventory[game.inv_activated];
    }
  }
}


//INVENTORY CLICKS
function on_event(EventType event, int data) {
  GUI *theGUI = gInventory1.OwningGUI;
  if (SC_CustomInvClicks == true) {
    //deselect current inventory item:
    if (event == eEventGUIMouseDown && player.ActiveInventory != null && data == theGUI.ID) {
      if ((mouse.IsButtonDown(eMouseRight) && SC_SwapLeftRight == false) || (mouse.IsButtonDown(eMouseLeft) && SC_SwapLeftRight == true)) {
        GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
        if (theControl==gInventory1) {
          player.ActiveInventory = null;
        }
      }
    }
    //look at inventory item:
    else if (event == eEventGUIMouseDown && player.ActiveInventory == null && data == theGUI.ID) {
      if ((mouse.IsButtonDown(eMouseRight) && SC_SwapLeftRight == false) || (mouse.IsButtonDown(eMouseLeft) && SC_SwapLeftRight == true)) {
        GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
        if (theControl==gInventory1) {
          InventoryItem *i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
          if (i != null) i.RunInteraction(eModeLookat);
        }
      }
    }
  }
}
SMF spam blocked by CleanTalk