Feedback animation in inventory

  • #1, by NovelSaturday, 16. November 2013, 19:31 11 years ago
    When my main character picks something up, I would like to show the interface and see an animation of a little smoke cloud, that dissapears ("puff") and leaves the new item.

    How would you solve this? Could I add the "puff" animation to an item? Or can I somehow make visionaire know which is the next free inventory slot and place an animation there?

    Newbie

    100 Posts


  • #2, by afrlmeSaturday, 16. November 2013, 20:49 11 years ago
    I think I wrote a simple script for the guy doing the Reemus game which we combined with animations.

    he had the popping in animations on the item animations themselves then after the item had been added we forced the animation to skip the popping part of the animation by setting the play from x frame (first frame) via lua. we also created a global script to check if item was already in inventory then don't play popping animation or something along those lines... I forget.

    I think I still have the .ved & scripts on my old laptop, so I'll see about digging them out the morrow; providing I still have them.

    I'm sure one of the VS devs could add something to the engine for adding global item pop in/out animations at some point; if they wouldn't mind doing so, of course wink

    Imperator

    7285 Posts

  • #3, by afrlmeSunday, 17. November 2013, 15:27 11 years ago
    ok so I haven't found the .ved file on my hd but I still have the .lua script file...
    I'll ask Zeebarf later, to see if he still has the .ved I gave him, as I don't have a clue where it has gone from my old paptop.

    anyway this was the mini global script I wrote for it.
    --[[
    Item Animation Control (v2) [very short method]
    Written by AFRLme
    -- * --
    label@alternatingfrequencies.com | aim, skype, trillian @ AFRLme
    --]]
    
    -- * let's create the function which sets the static frame for all items currently in the characters inventory * --
    function initItems()
     tblItmFrm = {} -- creates an empty table
     tblItmFrm["_temporary_"] = "" -- sets table to temporary
     tblItmFrm["items"] = game:getLink(VGameCurrentCharacter):getLinks(VCharacterItems) -- stores character items
     -- * --
     if table.maxn(tblItmFrm["items"]) > 0 then -- if items table is not empty then do ...
      for i = 1, table.maxn(tblItmFrm["items"]) do -- for i = 1 to total number of items do ...
       tblItmFrm["act_anim"] = getObject("ActiveAnimations[" .. tblItmFrm["items"][i]:getName() .. "]") -- store active animation
       tblItmFrm["gen_anim"] = getObject("Animations[" .. tblItmFrm["items"][i]:getName() .. "]") -- store general animation
       tblItmFrm["frames"] = tblItmFrm["gen_anim"]:getSprites(VAnimationSprites) -- store frames
       tblItmFrm["frames"] = table.maxn(tblItmFrm["frames"]) -- convert total of frames into an integer value
       -- * --
       --print("item: " .. tblItmFrm["items"][i]:getName() .. ", frames: " .. tblItmFrm["frames"]) -- prints item name & frame amount to log
       tblItmFrm["act_anim"]:setValue(VAnimationFirstFrame, tblItmFrm["frames"]) -- sets item animation to last frame & stops it from looping
      end
     end
    end
    

    essentially what he did was create the popping in animation & then in the last frame he added the static item icon & then what my script did was check at beginning of each scene was check which items character already had in their inventory & set the first frame to the last frame to prevent it from looping the item animation; far as I remember anyway.

    I think for this to work you just had to create an execute a script action in an at begin of scene action which included: initItems()

    I'm not 100% sure but I also think you had to add a simple line of lua to the final frame of each item you create which stops the animation from looping after it has got to last frame.
    getObject("ActiveAnimations[add item name here]"):setValue(VAnimationFirstFrame, add last frame number here for the item)
    

    controlling which frames are allowed to play is quite useful as it lets you create a animation & then select chunks from said animation via the use of VAnimationFirstFrame & VAnimationLastFrame.

    Imperator

    7285 Posts

  • #4, by NovelMonday, 18. November 2013, 17:55 11 years ago
    Thank you so much for your answer! I hope I will be able to try it out tonight. (Damn real life wink)

    Newbie

    100 Posts

  • #5, by afrlmeMonday, 18. November 2013, 18:34 11 years ago
    no problem...

    just let me know if you have any issues sorting it out. wink

    Imperator

    7285 Posts