[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Plugin to provide a bar of "action icons"

Plugin to provide a bar of "action icons"

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1  2 

Posted by Atomicoctobot   (19 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #17 on Mon 30 Mar 2009 08:52 PM (UTC)
Message
Also see this thread for an improved version that handles cooldown times:

http://www.gammon.com.au/forum/?id=9359

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Atomicoctobot   (19 posts)  [Biography] bio
Date Reply #18 on Mon 30 Mar 2009 09:21 PM (UTC)
Message
Brilliant. I am much obliged.
[Go to top] top

Posted by Atomicoctobot   (19 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] 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
[Go to top] top

Posted by Atomicoctobot   (19 posts)  [Biography] bio
Date Reply #21 on Sat 04 Apr 2009 04:26 AM (UTC)
Message
Ah, I think I understand now :)
[Go to top] top

Posted by Hanaisse   Canada  (114 posts)  [Biography] 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
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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.
[Go to top] top

Posted by Hanaisse   Canada  (114 posts)  [Biography] 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
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #25 on Sat 02 May 2009 11:13 AM (UTC)
Message
You need version 4.40. See: http://www.gammon.com.au/scripts/showrelnote.php?version=4.40&productid=0 for the changelog which details the function WindowDragHandler being added.


I guess Nick forgot to adjust the version attribute of the plugin. :)
[Go to top] top

Posted by Hanaisse   Canada  (114 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] 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
[Go to top] top

Posted by Edwin_r   (6 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] 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
[Go to top] 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.


90,443 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]