Inventory Item highlight/animate on mouse over events?

  • #1, von GlenfxDienstag, 12. April 2016, 20:32 Uhr vor 9 Jahren
    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?.

    Neuling

    72 Posts


  • #2, von ke4Dienstag, 12. April 2016, 21:10 Uhr vor 9 Jahren
    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)

    Tastenjunkie

    810 Posts

  • #3, von afrlmeDienstag, 12. April 2016, 21:33 Uhr vor 9 Jahren
    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.

    Foren Imperator

    7285 Posts

  • #4, von ke4Dienstag, 12. April 2016, 21:35 Uhr vor 9 Jahren
    I believe you did share something in a thread.

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

    Tastenjunkie

    810 Posts

  • #5, von GlenfxDienstag, 12. April 2016, 22:46 Uhr vor 9 Jahren
    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})
    

    Neuling

    72 Posts

  • #6, von afrlmeMittwoch, 13. April 2016, 00:36 Uhr vor 9 Jahren
    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.

    Foren Imperator

    7285 Posts

  • #7, von GlenfxMittwoch, 13. April 2016, 00:51 Uhr vor 9 Jahren
    Cool, Thank you.

    Yes, I think the code I posted was yours.

    Neuling

    72 Posts

  • #8, von afrlmeMittwoch, 13. April 2016, 01:04 Uhr vor 9 Jahren
    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.

    Foren Imperator

    7285 Posts