Thread Tools Display Modes
04/20/21, 12:41 PM   #1
DarkruneDK
 
DarkruneDK's Avatar
Join Date: Feb 2014
Posts: 2
Issue with SetClickSound (LUA)

Hi.

I am trying to write an addon entirely in LUA (just a preference I have), and I am having issues with the API SetClickSound.

I have tried the following:

Code:
SetLocator.UI.Window.Close:SetClickSound(ZO_ButtonBehaviorClickSound);
And

Code:
SetLocator.UI.Window.Close:SetClickSound("ZO_ButtonBehaviorClickSound");
I can't seem to make it work...
It it possible to do this? and if it is, how?
  Reply With Quote
04/20/21, 01:29 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Do you get any error message from lua that function is expected but nil?
If yes your lua control SetLocator.UI.Window.Close might not be a button, but something else, and thus does not provide SetClickSound.

I guess your problem is that you try to assign the button template ZO_ButtonBehaviorClickSound as sound:
https://github.com/esoui/esoui/blob/...mplates.xml#L3
It's just a virtual XML template that you are able to use via e.g. WINDOW_MANAGER:CreateControlFromVirtual specifing this as template name.
It uses the clicksound "click", so this would most likely be SOUNDS.CLICK (or similar).
And it is reused in other button types like ZO_DefaultButton (https://github.com/esoui/esoui/blob/...mplates.xml#L5) -> inherits="ZO_ButtonBehaviorClickSound".
So this is not a sound name, but a defined control with some XML attributes.

Try SetLocator.UI.Window.Close:SetClickedSound(SOUNDS.DIALOG_ACCEPT) or any other SOUNDS.<name> which you are able to find here https://wiki.esoui.com/Sounds (some are silent! So try them ingame via /script PlaySound(SOUNDS.<SOUNDNAME>) to hear if you hear anything.
Does this work and play the sound?

Or try the addon merTorchbug fixed and improved. It provides a list of all sounds ingame if you type /tbug, navigate to the "Sounds" tab. You can click them to play them. It also provides inspectors to check your addon's global variables and functions, and get information abou controls below the cursor using a keybinding, slash command /tbm or pressing right+left mouse+SHIFT key

If you do not want to set the click sound manually, but want your button to reuse/inherit from the ZO_ButtonBehaviorClickSound button template, you need to create your lua button control using this function here https://github.com/esoui/esoui/blob/...alvars.lua#L17 and specifying the "ZO_ButtonBehaviorClickSound" as templateName.
Or this function here https://github.com/esoui/esoui/blob/...alvars.lua#L21 to apply the template after creation of your control without a template.


One info: You do ne need to end lines with ; , but you can afaik.

Last edited by Baertram : 04/20/21 at 01:38 PM.
  Reply With Quote
04/20/21, 03:34 PM   #3
DarkruneDK
 
DarkruneDK's Avatar
Join Date: Feb 2014
Posts: 2
Thank you for the elaborate answer :-)

I am new to making addons for ESO, so this is very helpful (it's my first one, but I have made one for WoW, which also uses LUA).
I had some XML to begin with that used the inherit that you mentioned, but I wasn't really sure how to translate it into LUA.

I think I will try to use the SOUNDS.<SOUNDNAME> option, but I might check out the addon you suggested ☺

The semi-colon at the end is just me being used to work in C# and PHP. LUA doesn't seem to really care if it's there or not.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Issue with SetClickSound (LUA)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off