Basics - Character Interaction problem

  • #20, von afrlmeDonnerstag, 15. August 2013, 22:38 Uhr vor 12 Jahren
    I didn't say it wasn't possible! wink

    could you explain to me in some detail about exactly what you need it to do please?
    does it need to activate on mouse over or is it to play the animation when you add it to your inventory?

    if it's the latter one then as long as the final frame is the same as the static image then the script isn't overly complicated to make but the active on mouse over is a little more complicated as it involves creating tables to control loop amount or alternatively you could stop it animating on mouse out etc.

    Foren Imperator

    7285 Posts


  • #21, von zeebarfDonnerstag, 15. August 2013, 23:13 Uhr vor 12 Jahren
    It's the latter, it's an animation that only plays once as the item is added to the inventory and the final frame is the same as the static image. I basically want a little dynamic pop into the inventory instead of just appearing.

    Neuling

    13 Posts

  • #22, von afrlmeFreitag, 16. August 2013, 01:02 Uhr vor 12 Jahren
    ok dokie...

    I'll have a look into it the morrow, it's a wee bit late now.

    Foren Imperator

    7285 Posts

  • #23, von afrlmeFreitag, 16. August 2013, 03:22 Uhr vor 12 Jahren
    ok done wink


    add script as a definition script...
    --[[
    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
    


    to use it, create an at beginning of scene action for each non-menu scene & add an execute a script action part containing the following code
    initItems()

    yes it's as simple as that for freezing all the items already in the characters inventory to their last frame....

    ok so the next part requires some work from you! (check the attachments for reference)
    you will need to edit the final frame of each items animation & create an execute a script action part containing something along the lines of this...
    getObject("ActiveAnimations[add item name here]"):setValue(VAnimationFirstFrame, add last frame number)
    

    -- example
    getObject("ActiveAnimations[1_Weapon]"):setValue(VAnimationFirstFrame, 4)
    


    I've tested it...
    if no items are in inventory then InitItems() function does nothing.
    If you add an item to the inventory it will play the animation & then if you've done what I've said then it should remain on the last frame...
    if you remove an item & then re-add it, it will play animation from the beginning as it should do.

    *edit: annoying bloody code box still parsing emoticons...
    where the wink are is actually ... " ) quotation mark & a right bracket.

    Foren Imperator

    7285 Posts

  • #24, von zeebarfFreitag, 16. August 2013, 17:22 Uhr vor 12 Jahren
    Hmm, I can't seem to get it to work. I believe I've followed all the steps.

    I added the script as a definition script. Replaced "wink" line with " ) - I didn't leave a space between them though, I just did ")

    On the last frame of the item animation I added that script line and replaced the name and last frame number.

    And I added that line of code to the beginning of the scene action.

    I'm getting the same loop though? I must've blew it somewhere but I can't tell where.

    Neuling

    13 Posts

  • #25, von zeebarfFreitag, 16. August 2013, 17:24 Uhr vor 12 Jahren
    If you want you can send me that VED file and I can try to copy it directly into mine?


    Neuling

    13 Posts

  • #26, von afrlmeFreitag, 16. August 2013, 17:42 Uhr vor 12 Jahren
    could you send me some screenshots of what you've done please ?

    if you don't want to post them on here then you can send them to me via email: label (at) alternatingfrequencies dot com or via skype @ AFRLme

    the main script needs to be set as definition script via the script properties tab.

    the active animation name has to be written exactly the same as the items name - it's case sensitive & last frame number is the final frame (count frame 0 as 1 & go from there)

    Foren Imperator

    7285 Posts