First off, at a glance, you have a serious logic flaw in your if-then clauses. For instance, if you click the EmoteQS control while the nextEmote="/hug" but checkboxHug is not checked, then the emote will never change to another emote, it will simply get stuck since none of your conditions apply. I am assuming you simply want it to cycle through emotes but only performing the ones that are checked. If that is the case, then your if-then cases should fall through to the next available case when a checkbox is not selected so, in the example above where the next emote would be /hug but the hug checkbox is not checked, it should change the nextEmote to "/hail" so that when it falls through it will be testing against the next possible option. This assumes you only want a single, non-cyclic pass through the emotes.
If you want the flow to be cyclic (if you want it to cycle back to the first emote if all of the checkboxes following the next emote are unchecked) you have a second flaw. If you want it to cycle then your mechanism needs to be reworked so that you can know which was the initial emote tested (to avoid an endless loop) and it needs to be tested in a while loop or similar structure that will allow you to cycle back through the first elements until a checked option is true or you reach the starting point in which case you would simply stop and clear the emote text since no emotes would be checked.
Note, there is also an oddity with the MouseClick event handler for quickslots - if you assign a handler and left click the action is suppressed but the handler fires. If you right click, both the action and the handler fire.
Something along the lines of the following should work although I would have probably designed it slightly differently by making the checkboxes a table of controls which would have been used in place of the "emotes" table below
Code:
wSocialGuy.EmoteQS.MouseClick=function()
local emotes={{"/hug",checkboxHug},{"/hail",checkboxHail},{"/confused",checkboxConfused},{"/kiss",checkboxKiss}}
local index;
local startIndex=0;
for k,v in ipairs(emotes) do
if v[1]==nextEmote then
startIndex=k;
break;
end
end
if startIndex~=0 then
index=startIndex;
local done=false
while not done do
if emotes[index][2]:IsChecked() then
SetEmote(emotes[index][1]);
done=true
end
index=index+1
if index>#emotes then index=1 end
if index==startIndex then done=true end
if done then
nextEmote=emotes[index][1]
end
end
end
end