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

  • #1, by AkcayKaraazmakFriday, 11. September 2015, 01:56 9 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...

    Great Poster

    440 Posts


  • #2, by afrlmeFriday, 11. September 2015, 02:03 9 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.

    Imperator

    7278 Posts

  • #3, by AkcayKaraazmakFriday, 11. September 2015, 11:19 9 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.

    Great Poster

    440 Posts

  • #4, by afrlmeFriday, 11. September 2015, 11:57 9 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.

    Imperator

    7278 Posts

  • #5, by sebastianFriday, 11. September 2015, 12:21 9 years ago
    The Left-Click is only available in the Item Slot (Scene Object)

    Thread Captain

    2346 Posts

  • #6, by AkcayKaraazmakFriday, 11. September 2015, 12:35 9 years ago
    So mate, how I can use left click for the items in inventory? Is this impossible to do?

    Great Poster

    440 Posts

  • #7, by sebastianFriday, 11. September 2015, 13:08 9 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.

    Thread Captain

    2346 Posts

  • #8, by AkcayKaraazmakFriday, 11. September 2015, 13:15 9 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?

    Great Poster

    440 Posts

  • #9, by sebastianFriday, 11. September 2015, 13:32 9 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 ...

    Thread Captain

    2346 Posts

  • #10, by afrlmeFriday, 11. September 2015, 13:45 9 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.

    Imperator

    7278 Posts

  • #11, by AkcayKaraazmakFriday, 11. September 2015, 13:48 9 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 :\

    Great Poster

    440 Posts