Highlighting given item in inventory?

  • #1, by chrisgTuesday, 07. April 2020, 08:41 5 years ago
    Is there a way to play an animation, or some effect when an item is first given to the player? 

    I can add something to the action when the item is given, and i think i can set an active state of a button in the inventory, but i dont know how to work out which inventory slot the item is at?

    Newbie

    16 Posts


  • #2, by chrisgTuesday, 07. April 2020, 09:09 5 years ago
    I thought i could do this with the animation on the item, and have it only loop once, but it seems it loops infinitely even if i set it to one.

    Newbie

    16 Posts

  • #3, by afrlmeTuesday, 07. April 2020, 12:49 5 years ago
    If you only add an animation & no static image then it would only play the animation, & if you were to add a bit of Lua script to the animation then you could force it to loop a specific frame or loop between a specific range of frames. wink

    Also has recently been discussing on our discord about a system where the item sprite pops up on the screen (above the characters head in their case) briefly before fading out, whenever the player picks up a new item. My point is that you have various solutions you could try implementing.

    Imperator

    7285 Posts

  • #4, by chrisgTuesday, 07. April 2020, 23:57 5 years ago
    Thanks - those are good leads. I had forgotten i can add an action to any frame, I think this will get me exactly what I want, cheers!

    Newbie

    16 Posts

  • #5, by chrisgWednesday, 08. April 2020, 00:11 5 years ago
    For the next person trying to solve this problem:

    • The part I was missing was how to address the animation for the item, and tell it when to stop. 
    • After the suggestion above, I found this old forum post:  https://www.visionaire-studio.net/forum/thread/feedback-anim...
    • There is a bunch of sample code but I only needed to use a single line of it, on my final frame of the animation
    • On the last frame, I clicked on edit (pencil), add action, action type is 'Execute script'
    • The full contents of the script is: "getObject("ActiveAnimations[add item name here]"):setValue(VAnimationFirstFrame, add last frame number here for the item)" 
    • Once you have done that, the animation plays once, and stops on the last frame when it is added to your inventory - so you can do a few frames to draw attention and then stop on the normal icon.

    Newbie

    16 Posts

  • #6, by afrlmeWednesday, 08. April 2020, 12:03 5 years ago
    The only issue with that solution is that whenever the game is loaded & interface is shown it will likely play the animation fully again. Also you are using the old longhand scripting method, but that doesn't really matter.

    A cleaner solution would be to force the first frame of the animation & maybe use a condition or value, & check in the first frame if the condition or value = something & if not then change it to that else force it to loop the first frame only.

    So your action block for the first frame would look something like this...

    if conditions "example" is false
     set condition "example" to true
    else
     execute a script >

    ActiveAnimations["item name"].FirstFrame =  1
    
    ActiveAnimations["item name"].LastFrame = 1

    end if

    Imperator

    7285 Posts

  • #7, by chrisgWednesday, 08. April 2020, 22:58 5 years ago
    Awesome - will test this out, thankyou!

    I haven't gotten as far as saving and loading yet so hadn't anticipated that issue.


    Newbie

    16 Posts