Ok, I've used your suggestion to create the following script and it's not working quite right. What I am attempting to do is to create a single button that cycles through a number of emotes and to send that emote each time the button is displayed.
The script is cycling through the various aliases, but does not send the emote on each keypress of the button. It will do something weird however when you untick one of the emotes, it will get stuck on the emote preceeding the unticked emote and send that one sucessfully... can you spot what I am doing wrong please? Why is getting stuck when the IF/THEN/END statement should skip to the next statement and it's sending it only then? Does it have something to do with the RETURN in that IF/THEN statement? Is it possible to return out of the function successfully each on each keypress? It has me stumped!
Code:
-- Set SocialGuy Window Positions
local Settings = Turbine.PluginData.Load(Turbine.DataScope.Character, "SocialGuySettings");
local WindX,WindY=Turbine.UI.Display:GetWidth()/2-100,Turbine.UI.Display:GetHeight()/2-100;
if Settings~=nil then
if Settings["WindPosX"]~=nil then WindX=Settings["WindPosX"] end
if Settings["WindPosY"]~=nil then WindY=Settings["WindPosY"] end
end
-- Create Window
wSocialGuy = Turbine.UI.Lotro.Window();
wSocialGuy:SetSize(500,300);
wSocialGuy:SetPosition(WindX,WindY);
wSocialGuy:SetText("SocialGuy by Radicus");
-- if Settings["WindState"] == true then wSocialGuy:SetVisible(true) end
-- Create Heading Label
xpos = 25;
ypos = 35;
yinc = 25;
label = "Emotes";
labelEmotes = Turbine.UI.Label();
labelEmotes:SetParent(wSocialGuy);
labelEmotes:SetText(label);
labelEmotes:SetPosition(wSocialGuy:GetWidth()/4,ypos)
labelEmotes:SetFont(Turbine.UI.Lotro.Font.TrajanPro14);
labelEmotes:SetForeColor(Turbine.UI.Color(1,1,0));
labelEmotes:SetSize(wSocialGuy:GetWidth()/2,20);
labelEmotes:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleCenter);
-- Create Checkboxes
ypos=ypos+yinc;
checkboxHug = Turbine.UI.Lotro.CheckBox();
checkboxHug:SetPosition(xpos,ypos);
checkboxHug:SetCheckAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
checkboxHug:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
checkboxHug:SetFont(Turbine.UI.Lotro.Font.TrajanPro14);
checkboxHug:SetForeColor(Turbine.UI.Color(1,1,0));
checkboxHug:SetText(" /hug - The Adorable");
checkboxHug:SetParent(wSocialGuy);
checkboxHug:SetSize(180,20);
checkboxHug:SetChecked(true);
ypos=ypos+yinc;
checkboxHail = Turbine.UI.Lotro.CheckBox();
checkboxHail:SetPosition(xpos,ypos);
checkboxHail:SetCheckAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
checkboxHail:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
checkboxHail:SetFont(Turbine.UI.Lotro.Font.TrajanPro14);
checkboxHail:SetForeColor(Turbine.UI.Color(1,1,0));
checkboxHail:SetText(" /hail");
checkboxHail:SetParent(wSocialGuy);
checkboxHail:SetSize(180,20);
checkboxHail:SetChecked(true);
ypos=ypos+yinc;
checkboxConfused = Turbine.UI.Lotro.CheckBox();
checkboxConfused:SetPosition(xpos,ypos);
checkboxConfused:SetCheckAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
checkboxConfused:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
checkboxConfused:SetFont(Turbine.UI.Lotro.Font.TrajanPro14);
checkboxConfused:SetForeColor(Turbine.UI.Color(1,1,0));
checkboxConfused:SetText(" /confused");
checkboxConfused:SetParent(wSocialGuy);
checkboxConfused:SetSize(180,20);
checkboxConfused:SetChecked(true);
ypos=ypos+yinc;
checkboxKiss = Turbine.UI.Lotro.CheckBox();
checkboxKiss:SetPosition(xpos,ypos);
checkboxKiss:SetCheckAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
checkboxKiss:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
checkboxKiss:SetFont(Turbine.UI.Lotro.Font.TrajanPro14);
checkboxKiss:SetForeColor(Turbine.UI.Color(1,1,0));
checkboxKiss:SetText(" /kiss");
checkboxKiss:SetParent(wSocialGuy);
checkboxKiss:SetSize(180,20);
checkboxKiss:SetChecked(true);
-- Create Send Emote Button
ypos=ypos+yinc;
wSocialGuy.GoButton=Turbine.UI.Label();
wSocialGuy.GoButton:SetParent(wSocialGuy);
wSocialGuy.GoButton:SetSize(50,15);
wSocialGuy.GoButton:SetPosition(wSocialGuy:GetWidth()/4,ypos)
wSocialGuy.GoButton:SetText("Be Sociable");
wSocialGuy.GoButton:SetBackColor(Turbine.UI.Color(.3,.3,.3)); -- needed to prevent the quickslot icon boundary from displaying
wSocialGuy.GoButton:SetMouseVisible(false);
currentEmote="/hug"; -- sets the starting emote
nextEmote=currentEmote;
wSocialGuy.EmoteQSBack=Turbine.UI.Control(); -- used to prevent the quickslot from drawing outside the mask bounds
wSocialGuy.EmoteQSBack:SetParent(wSocialGuy);
wSocialGuy.EmoteQSBack:SetSize(wSocialGuy.GoButton:GetWidth(),wSocialGuy.GoButton:GetHeight())
wSocialGuy.EmoteQSBack:SetPosition(wSocialGuy.GoButton:GetLeft(),wSocialGuy.GoButton:GetTop())
wSocialGuy.EmoteQSBack:SetZOrder(-1);
wSocialGuy.EmoteQS = Turbine.UI.Lotro.Quickslot();
wSocialGuy.EmoteQS:SetParent(wSocialGuy.EmoteQSBack);
-- note, if there is any chance that the alias could contain a special (non-ASCII) character then you should use the SetData method to assign it to avoid a bug in the Shortcut constructor
wSocialGuy.EmoteQS:SetSize(wSocialGuy.GoButton:GetWidth()+34,wSocialGuy.GoButton:GetHeight()+34)
wSocialGuy.EmoteQS:SetPosition(-34,-34);
wSocialGuy.EmoteQS:SetAllowDrop(false);
wSocialGuy.EmoteQS.DragDrop=function(sender)
local sc=Turbine.UI.Lotro.Shortcut(Turbine.UI.Lotro.ShortcutType.Alias,"");
sc:SetData(currentEmote);
sender:SetShortcut(sc);
Turbine.Shell.WriteLine(sc);
end
function SetEmote(e)
wSocialGuy.EmoteQS:SetShortcut(Turbine.UI.Lotro.Shortcut(Turbine.UI.Lotro.ShortcutType.Alias, e));
wSocialGuy.EmoteQS.AliasText=e;
currentEmote=e;
end
wSocialGuy.EmoteQS.MouseClick=function()
if checkboxHug:IsChecked() == true and nextEmote == "/hug" then
SetEmote(nextEmote);
nextEmote="/hail";
return;
end
if checkboxHail:IsChecked() == true and nextEmote == "/hail" then
SetEmote("/hail");
nextEmote="/confused";
return;
end
if checkboxConfused:IsChecked() == true and nextEmote == "/confused" then
SetEmote("/confused");
nextEmote="/kiss";
return;
end
if checkboxKiss:IsChecked() == true and nextEmote == "/kiss" then
SetEmote("/kiss");
nextEmote="/hug";
return;
end
end