edited January 2020 in ORK Scripting
Hi,

Is it possible to get the Equipment Part that the mouse cursor is currently hovering over in equipment menu? This is what I have so far, I don't know if it's optimal at all because I couldn't figure out any other way than to read the tooltip data. And also it doesn't obviously work if the slot is not empty:
if (Input.GetMouseButtonDown (0)) {
if (ORK.GUI.Tooltip.TooltipContent != null) {
string clickedName = ORK.GUI.Tooltip.TooltipContent.GetContent ().text;
EquipmentPart equipmentPart = null;

for (int i = 0; i < ORK.EquipmentParts.Count; i++) {
if (ORK.EquipmentParts.GetName (i) == clickedName) {
equipmentPart = ORK.EquipmentParts.Get (i);
}
}

if (equipmentPart != null) {
Debug.Log (player.Equipment [equipmentPart.ID].Equipped);
}
}
}



Edit: I ended up doing a graphic raycast and doing a switch case to check the name of the choice button and assigning that to an ID variable. I hope theres a better way though because this is very ugh
Post edited by pesukarhu on
  • Tooltip is probably the easiest way to do it.

    For an empty slot, the EquipmentPart setting itself is used, i.e.:
    EquipmentPart part = ORK.GUI.Tooltip.TooltipContent as EquipmentPart;
    if(part != null)
    {
    // it's an equipment part
    }

    will already give you the equipment part.

    If something is equipped on it, it'll be the EquipShortcut of the equipment and you'd have to search the menu user's equipment for the correct part:
    EquipShortcut equip = ORK.GUI.Tooltip.TooltipContent as EquipShortcut;
    if(equip != null)
    {
    Combatant user = ORK.MenuScreens.Get(menuID).Combatant;
    if(user != null)
    {
    for(int i=0; i<ORK.EquipmentParts.Count; i++)
    {
    if(user.Equipment[i].Equipment == equip)
    {
    // that's the equipment part
    }
    }
    }
    }

    menuID is the ID/index of your menu screen.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Oooh! I didn't know tooltip content could be type checked like that. That makes it a lot easier. What I have now is working, but I'll do what you suggested instead as it's waaay more elegant. Thank you!
  • edited January 2020
    Since the TooltipContent returns an interface (IContentSimple, which is the base for all 'languaged' data in ORK), it could be pretty much everything in ORK that uses that interface.

    So, it could be a setting, one of the shortcuts, a combatant, a scene object component, etc.
    If you're looking for something, just try checking it like that, and if it's not null, you're already good to go :)
    And if you just need some content information (e.g. name, description), you can directly access it via the interface.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.