Highlighting given item in inventory?

  • #1, by chrisgTuesday, 07. April, 08:41 2 months 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

    15 Posts


  • #2, by chrisgTuesday, 07. April, 09:09 2 months 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

    15 Posts

  • #3, by afrlmeTuesday, 07. April, 12:49 2 months 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

    6772 Posts

  • #4, by chrisgTuesday, 07. April, 23:57 2 months 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

    15 Posts

  • #5, by chrisgWednesday, 08. April, 00:11 2 months 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

    15 Posts

  • #6, by afrlmeWednesday, 08. April, 12:03 2 months 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
    1
    2

    end if

    Imperator

    6772 Posts

  • #7, by chrisgWednesday, 08. April, 22:58 2 months 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

    15 Posts

Write post