Help with assigning Alias to a Button (possible?)
Just wondering it's possible to add an alias to a button rather than a quickslot, or somehow tie the two together?
I'm trying to code a button to send an emote when pressed. I've had a look at the coding for ChatEdit by Galuhad, but can't decipher is coding easily. I've noticed when you create some text it updates the button so that when you hover the mouse over the button, it displays what the alias is and sends it to the chat channel when clicked. Can someone offer an alternative piece of code to achieve this? Here's my effort so far. eg. Code:
-- Create Emote Button |
There is an example of masking a quickslot behind another control to simulate a quickslot button in the Writing LotRO Plugins for Noobs thread:
http://forums.lotro.com/showthread.p...91#post5824491 The third button example is the quickslot. You can also find similar code in the MoorMap main.lua file to implement the Quick Annotation tool as well as in many other plugins, Plugin Compendium which uses quickslots behind labels to send text to chat comes to mind. I'm sure there are many other examples. It's usually overkill to put an actual Button in front of the quickslot since you need to use SetMouseVisible(false) on the masking object so that mouse events go through to the quickslot. However, I can think of at least one case where I have put a real button in front and by controlling its mouse visibility was able to implement some neat functionality. Typically though, you would either use a Control object and just set a background image to make it look like a button or use a Label object if you want text. Here's some additional comments I recently sent to another user regarding using quickslots masked behind other controls: Quote:
Code:
-- Create Emote Button |
I'd be the first to admit that I am not the best coder, so apologies if you are having a hard time understanding my code (I suffer the same problem when I leave a project and return to it at a later stage). What Garan said is correct and is basically what I did it ChatEdit, and pretty much every other plugin that sends something to the chat window. Unfortunately the API does not allow you to send messages through any hard code, the only loop hole we can manage is by masking the alias in a quickslot behind another control. That way we are not sending the message per se, the user is instead clicking a quickslot with the alias loaded into it. Hopefully Turbine will be more trusting one day and give us better functionality.
|
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 |
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() |
Try this:
Code:
In the code above this is how I've done it. I also put your emotes into a table which will make it easier for you if you want to expand the plugin in future with more emotes as you will not need to change any of the code except the table entries. Also another bug I found was that the emotes wouldn't fire because the alias is changed mid-event during the mouseclick. If you unticked all but one emote it would then work as the alias would not be changing. To get around this I put the setEmote call in the quickslot control's Update() function and used the mouseclick event to SetWantsUpdates() to true. I've tested this ingame and found it to work efficiently. |
Thanks guys, appreciate the input! Keep a look out for the release version that I'll be posting shortly.
|
Unfortunately the API does not allow you to send messages through any hard code, the only loop hole we can manage is by masking the alias in a quickslot behind another control. That way we are not sending the message per se, the user is instead clicking a quickslot with the alias loaded into it. Hopefully Turbine will be more trusting one day and give us better functionality.
|
All times are GMT -5. The time now is 12:23 AM. |
vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI