Binding function with a default Visionaire action.

  • #1, by ke4Friday, 08. January 2016, 14:51 9 years ago
    Hi,

    i would like to have a notification everytime when item is added into the inventory so that player could not missed that new item was added. Can i somehow bind my function with the add item event action part? So i wouldn't have to call the function everytime i would be adding item. Thanks.

    Key Killer

    810 Posts


  • #2, by AkcayKaraazmakFriday, 08. January 2016, 14:58 9 years ago
    You mean, whenever user takes an item, some kind of alert on screen pops out?

    Great Poster

    440 Posts

  • #3, by ke4Friday, 08. January 2016, 15:04 9 years ago
    Yes, it would show the item in the corner for a while with some animation.

    Key Killer

    810 Posts

  • #4, by sebastianFriday, 08. January 2016, 18:25 9 years ago
    As far as i know there is no Lua Hook which could be trigegred when an Item gets added.
    What you could do is calling also an action when adding an item which starts several stuff like:
    "take sound effect"
    "show interface which indicates a new item"
    "wait"
    "hide interface which indicates a new item"

    Thread Captain

    2346 Posts

  • #5, by afrlmeFriday, 08. January 2016, 18:42 9 years ago
    well... you could create a loop that listens out for when the item table max value increases. then you could return the last item added to start an animation or something.

    The hooks are essentially main loops that have been pre-created by the devs already. wink

    inv = #(game.CharacterItems)
    
    function new_item()
     if #(game.CharacterItems) > inv then
      inv = #(game.CharacterItems)
      print(game.CharacterItems[inv]:getName())
      startAnimation("Animations["inv_"..game.CharacterItems[inv]:getName()])
     end
    end
    
    registerEventHandler("mainLoop", "new_item")
    


    I don't know if the code will work. Wrote it off the top of my head. Anyway... you would also need to reduce the inv value each time you removed an item from your inventory...
    inv = inv - 1
    

    Imperator

    7285 Posts

  • #6, by ke4Friday, 08. January 2016, 18:47 9 years ago
    @Sebastian
    The point is that i dont want to go thourgh the whole game and add this action. It's possible that i would miss some places & it's just bummer.

    @AFRLme
    Nice idea, won't be that loop slowing the game down? ( not first loop in my game )

    Key Killer

    810 Posts

  • #7, by afrlmeFriday, 08. January 2016, 18:55 9 years ago
    no idea. You'd have to try it & see. It's only the one if query.

    Imperator

    7285 Posts

  • #8, by ke4Friday, 08. January 2016, 19:03 9 years ago
    Thanks i'm gonna try it.
    I will text some echo here then.

    Key Killer

    810 Posts

  • #9, by ke4Saturday, 09. January 2016, 09:59 9 years ago
    The loop works fine, it's not slowing the game. I didn't know you can acces item by number like this.
    game.CurrentCharacter.Items[inv]
    


    I would like to avoid using animations, but i don't know if what i'm trying to do is not overcomplicated.

    As it's stored in interface, i can't create objects there, so i can't animate the Scale.

    So my idea is something like this. To use the images from the items.

    1 Show interface
    2 button.animation = Current_Item.animation.firstFrame
    3 Play animation
    4 Animate the size of the animation
    5 Animate the visibility of the interface
    6 Stop the animation, hide interface

    The end result should be just zoom of the item image with a fading efect of visibility.
    There are fields like ButtonAnimation or AnimationFirstFrame but i can't put this together grin

    Key Killer

    810 Posts