Inventory Item highlight/animate on mouse over events?

  • #1, by GlenfxTuesday, 12. April 2016, 20:32 8 years ago
    Hey I made a search under "inventory Items" and didn't find a topic with my question, sorry if there is one under a different title.

    Anyway, I was looking at the items tab and there isn't an "on mouse" enter/leaving setting for the inventory items as well as an active_inactive icon image or animation. Will this be a feature in a future release?.

    Newbie

    72 Posts


  • #2, by ke4Tuesday, 12. April 2016, 21:10 8 years ago
    There is a way to achieve what you want. You would need to create a loop that checks for hovered objects.

    To register a loop

    function function_name()
    end
    
    registerEventHandler("mainLoop", "function_name")
    


    You can retrive the name of current object, it returns nill if there isn't any

    game.CurrentObject:getName()
    


    And you can retrive the items

    game.CurrentCharacter.Items
    


    It returns table of items, you would need to check if any of the items is equal to current object.
    And for changing the image of item, you need to use an animation for items and then you need to set the frames that should be looped.

    http://wiki.visionaire-tracker.net/wiki/SetAnimFrames_(CMS)

    Key Killer

    810 Posts

  • #3, by afrlmeTuesday, 12. April 2016, 21:33 8 years ago
    I thought I shared a script for this a little while ago? I'm sure it's either in a thread on here or on the wiki.

    Imperator

    7278 Posts

  • #4, by ke4Tuesday, 12. April 2016, 21:35 8 years ago
    I believe you did share something in a thread.

    Edit: i found this thread
    http://www.visionaire-studio.net/forum/thread/item-highlight...

    Key Killer

    810 Posts

  • #5, by GlenfxTuesday, 12. April 2016, 22:46 8 years ago
    humm, the topic didn't show in my search but thanks for the link to it. I mostly wanted to know if the function would be implemented in a future release.

    Anyway I tried both Simon's and AFRLme scripts from that topic, both seem easy to work with though I have a question.

    I created the two frame animation in the item with both instances and added an execute script to the first frame, but in the game the inventory shows the animated two frames in the item until I hover the mouse over it, and then it works as intended.
    Am I doing something wrong?, how do I make the inventory not animate the icon every time it opens?.

    This is the script I used in the first animation frame of the item:

    prevItem = nil -- initial value of previously highlighted item
    
    function checkItemStatus()
     if prevItem ~= nil then prevItem:setValue(VAnimationFirstFrame, 1); prevItem:setValue(VAnimationLastFrame, 1); prevItem = nil end
     -- + --
     if game:getLink(VGameCurrentObject):getId().tableId == eObjects then
      if game:getLink(VGameCurrentObject):getBool(VObjectIsItem) then
       prevItem = getObject("ActiveAnimations[" .. game:getLink(VGameCurrentObject):getName() .."]"); prevItem:setValue(VAnimationFirstFrame, 2); prevItem:setValue(VAnimationLastFrame, 2)
      end 
     end
    end
    
    function onMouseEvent(eventType)
     if eventType == eEvtMouseMove then checkItemStatus() end
    end
    
    registerEventHandler("mouseEvent", "onMouseEvent", {eEvtMouseMove})
    

    Newbie

    72 Posts

  • #6, by afrlmeWednesday, 13. April 2016, 00:36 8 years ago
    That's a definition script. It should be added to the script section of the editor.

    Inside of the first frame of your items you should add an execute a script action part containing something along the lines of...
    ActiveAnimations["name"].AnimationFirstFrame = 1
    ActiveAnimations["name"].AnimationLastFrame = 1
    

    ... this will lock the animation to the first frame as soon as the animation starts playing.

    My script above (I assume it's mine) is a sort of loop that only needs to be declared once as it is called each time you move the mouse. Looking at it, it looks like I wrote it before we had shorthand scripting support.

    Imperator

    7278 Posts

  • #7, by GlenfxWednesday, 13. April 2016, 00:51 8 years ago
    Cool, Thank you.

    Yes, I think the code I posted was yours.

    Newbie

    72 Posts

  • #8, by afrlmeWednesday, 13. April 2016, 01:04 8 years ago
    Quick note: if you plan on using the dragged item option then the animations of those cursors will be exactly the same as whatever your inventory animations are currently displaying.

    Imperator

    7278 Posts