License from €75
DE EN FR ES IT CZ

How to play a sound when u click an item in inventory?

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

  1. · 12 years ago
    Hi mates,

    How I can play a sound when I click an item in the inventory? And also how to play a sound when you mouse over an item in the inventory?

    Thank you...
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license. Forum readers get the Indie Bundle 15 % off with the code FORUM15: €84.15 instead of €99, valid until 31 Dec 2026.

    Get 15 % off Try it for free
  3. · 12 years ago
    Add some actions to the items themselves in the item tab.

    On mouse over actions for adding some play sound action parts & maybe same for left click (immediate) action.
  4. · 12 years ago
    Hi Lee, but there is no left_click action for the items in item tab. Just double click, right click, mouse wheel ... but no left_click. I tried Immediate execute command with command "action" which is my action cursor. I select the item form the list also tried any and wrote to code playSound() ... but it doest work.
  5. · 12 years ago
    Could you post some screenshots of what you did? & did you try out the on mouse enter / leaves actions?

    You want to be using the play sound action part - Lua shouldn't need to be involved at all.

    P.S: It is actually possible to check with Lua script & mouseEvent handler when an item, object or character is below your cursor on mouse move, but it would trigger the sound each time you moved as it wouldn't have the same countermeasure system in place as the on mouse enter / leaves actions as they only trigger once & will not be triggered again until you left the object. I guess what you could do is create a state, So if mouse over an object that is an item & state is false then play sound & then set state to true & have it set state to false when mouse is over nothing. I guess it would save you from having to create action parts for each item. You could also use the mouse event to trigger sound on left click too.

    I've not the time to write an example script / step by step at the minute though.
  6. · 12 years ago
    The Left-Click is only available in the Item Slot (Scene Object)
  7. · 12 years ago
    So mate, how I can use left click for the items in inventory? Is this impossible to do?
  8. · 12 years ago
    should the same sound play on every item or is it specific stuff per individual item?
    When everything is the same you can go to your inventory interface and set the left-click option on the slot objects.
  9. · 12 years ago
    Same sound, I did what you told and it worked BUT, it also plays the sound on the empthy slots which doesnt have any item. How I can query if slot is empty or no so it play the sound or no?
  10. · 12 years ago
    you could try to check if the current object under the cursor is an item (actionpart " If current object is item") and only then play the sound. But i dont know if it also triggers when there is no item in the placeholder ...
  11. · 12 years ago
    Hmm I meant for you to add the actions to the items themselves, not the inventory slots! grin

    The thing is that even if you were to add the query if item exists under cursor to the inventory slot on mouse action parts, it still may not trigger the sound as more likely than not there will be some white space between the beginning of the inventory slot polygon & the object itself. You can try it though.
  12. · 12 years ago
    Yea Lee but there is no possibity to write an action for the left click. Just double click, right click, mose roll over etcc but no left click :\

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?