Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Plugins
➜ Plugin to provide a bar of "action icons"
Plugin to provide a bar of "action icons"
|
Posting of new messages is disabled at present.
Refresh page
Pages: 1
2
Posted by
| Atomicoctobot
(19 posts) Bio
|
Date
| Reply #15 on Mon 30 Mar 2009 04:21 PM (UTC) |
Message
| I'm just trying to set it up so that the command "say such and such" is sent when the menu option is chosen. I'm completely lost. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #16 on Mon 30 Mar 2009 07:31 PM (UTC) |
Message
| You just need a slight change to what I posted before.
After calling the WindowMenu function, the variable "result" is either an empty string, or the word in the menu. So you test for an empty string (which happens if you press <esc> to cancel the menu), you simply send "say " concatenated with the result, like this:
-- button 3
{
icon = "spear2.png",
tooltip = "Special Attacks",
script = function ()
local result = WindowMenu (win,
WindowInfo (win, 14), -- x
WindowInfo (win, 15), -- y
"Backstab|Stun|Kick|Taunt") -- menu items
if result ~= "" then
Send ("say " .. result)
end -- if
end, -- function
}, -- end of button 3
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #17 on Mon 30 Mar 2009 08:52 PM (UTC) |
Message
| |
Posted by
| Atomicoctobot
(19 posts) Bio
|
Date
| Reply #19 on Fri 03 Apr 2009 05:21 PM (UTC) |
Message
| How would one set up the drop down menu so that the options listed simply point to a string of commands, rather than act as part of the command itself?
This is what I'm trying to accomplish:
-- button 1
{
icon = "spear2.png",
tooltip = "Special Attacks",
script = function ()
local result = WindowMenu (win,
WindowInfo (win, 14), -- x
WindowInfo (win, 15), -- y
"special attack 1") -- menu items
if result = "special attack 1" then
Send ("say backstab/nbackstab opponent/nbury corpse")
end -- if
end, -- function
}, -- end of button 1 | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #20 on Sat 04 Apr 2009 03:46 AM (UTC) |
Message
| You are on the right track. However comparing equal is == in Lua, not =.
Also, remember that a newline is \n not /n.
So, something like this should work:
if result == "special attack 1" then
Send ("say backstab\nbackstab opponent\nbury corpse")
end -- if
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Hanaisse
Canada (114 posts) Bio
|
Date
| Reply #22 on Fri 01 May 2009 10:14 PM (UTC) Amended on Fri 01 May 2009 10:15 PM (UTC) by Hanaisse
|
Message
| After installing this plug-in (the improved Mar 29th version on page 1 changing only the button info) I get this error output to the mud..
Run-time error
Plugin: Icon_Bar (called from world: Fury Newest2)
Function/Sub: OnPluginInstall called by Plugin Icon_Bar
Reason: Executing plugin Icon_Bar sub OnPluginInstall
[string "Plugin"]:293: attempt to call global 'WindowDragHandler' (a nil value)
stack traceback:
[string "Plugin"]:293: in function <[string "Plugin"]:196>
Error context in script:
289 : "", -- MouseUp
290 : "Drag to move", -- tooltip text
291 : 10, 0) -- arrow (NS/EW) cursor
292 :
293*: WindowDragHandler(win, "_", "dragmove", "dragrelease", 0)
294 :
295 : if GetVariable ("enabled") == "false" then
296 : ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
297 : EnablePlugin (GetPluginID (), false)
Any help is appreciated, I'm looking forward to trying it :)
|
aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000 | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #23 on Fri 01 May 2009 10:45 PM (UTC) |
Message
| My guess is that you are using an old version of MUSHclient. Take a look at the Announcements forum for the latest released version. | Top |
|
Posted by
| Hanaisse
Canada (114 posts) Bio
|
Date
| Reply #24 on Fri 01 May 2009 10:54 PM (UTC) |
Message
| As soon as I read that I thought 'doh!' but I'm using 4.37, which is the requirement of version 2.0 of this plug-in. |
aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000 | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #25 on Sat 02 May 2009 11:13 AM (UTC) |
Message
| |
Posted by
| Hanaisse
Canada (114 posts) Bio
|
Date
| Reply #26 on Sat 02 May 2009 04:23 PM (UTC) |
Message
| Well grrrr @ Nick for that error :p
That was exactly it, this plug-in requires 4.40 not 4.37, and it works beautifully. Very cool and very handy trick.
The upgrade however brought about another issue but I'll make a new post about it. |
aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000 | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #27 on Sat 02 May 2009 10:35 PM (UTC) |
Message
| Ooops. That is what comes from adding functionality to an existing plugin. ;)
I have amended both posts. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Edwin_r
(6 posts) Bio
|
Date
| Reply #28 on Tue 31 Jul 2012 02:27 AM (UTC) Amended on Tue 31 Jul 2012 02:29 AM (UTC) by Edwin_r
|
Message
|
Nick Gammon said:
Each button can have up to four entries:
icon - filename of the image to draw
tooltip - what to show if you hover the mouse over the button
send - what to send to the MUD
script - a script function to call
--]]
buttons = {
-- button 1
{
icon = "HealIcon.png", -- icon image
tooltip = "Heal self", -- tooltip help text
send = "cast 'lesser heal' self", -- what to send
}, -- end of button 1
-- button 2
{
icon = "SwordIcon.png",
tooltip = "Attack",
send = "kill @target",
}, -- end of button 2
-- button 3
{
icon = "SparkIcon2.png",
tooltip = "Cast Fireball",
send = "cast fireball",
script = function ()
ColourNote ('white', 'green', 'script test')
end, -- function
}, -- end of button 3
--> add more buttons here
-----------------------------------------
Hi
I was wondering if there is some restrictions of certain kind of functions called by the buttons. i would like to disable some groups of triggers, so i wrote:
-- button 3
{
icon = "peace.png",
tooltip = "Pacific Mode",
send = "say hello",
script = function ()
EnableTriggerGroup ("attack", false)
end,
}, -- end of button 3
} -- end of buttons table
...but it didn't work, and the button 3 of your example seems to work perfecty. Mine says hello, that's ok, but can't disable the "attack" group of triggers. Thanks for your comments. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #29 on Tue 31 Jul 2012 06:05 AM (UTC) |
Message
| That should work. Where is the trigger group? In a plugin? Or the main world?
Actually, enabling a trigger group would not cross plugin boundaries, that is probably the problem.
What you could do is make an alias in the main world (eg. EnableAttackGroup) that you execute from the button, eg.
Execute ("EnableAttackGroup")
So the button "sends" EnableAttackGroup, the alias in the main world picks it up, and then this alias can enable the group.
The ColourNote works because that affects the output window, not a specific plugin's triggers. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
102,118 views.
This is page 2, subject is 2 pages long:
1
2
Posting of new messages is disabled at present.
Refresh page
top