DE EN FR ES IT CZ

Binding function with a default Visionaire action.

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 11 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.
  2. New to Visionaire Studio?

    Create point and click adventures without coding. The free version covers up to 25 scenes per project. For more scenes or to earn money with your game, you need a license.

    See the Indie Bundle Try it for free
  3. · 11 years ago
    You mean, whenever user takes an item, some kind of alert on screen pops out?
  4. · 11 years ago
    Yes, it would show the item in the corner for a while with some animation.
  5. · 11 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"
  6. · 11 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
    
  7. · 11 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 )
  8. · 11 years ago
    no idea. You'd have to try it & see. It's only the one if query.
  9. · 11 years ago
    Thanks i'm gonna try it.
    I will text some echo here then.
  10. · 11 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

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?