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

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Toggle Switches for Plugins

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Toggle Switches for Plugins

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Pages: 1  2 

Posted by LupusFatalis   (154 posts)  [Biography] bio
Date Reply #15 on Tue 16 Jun 2009 05:10 AM (UTC)  quote  ]
Message
Hmm... I copied that, the part that checks to see if its disabled when it loads the bar works fine. And the button toggles it on and off, but it only toggles the contrast to normal. Copied exactly what you have.
buttons = {

 -- button 1
 {
  icon = "search_32.png",
  tooltip = "Underdark Mapper",
  target_plugin = "aba6daf3fb30699071cb5d05",
  script = function (n) 
            
            local id = buttons [n].target_plugin
            
            local f = frames [n]  -- where is image?
            local x1, y1, x2, y2 = f.x1, f.y1, f.x2, f.y2
            
            -- redraw the image
            WindowDrawImage(win, n, 
                    x1 + 1, y1 + 1,   -- left, top
                    x2 - 1, y2 - 1,  -- right, bottom
                    2)  -- mode - stretch or shrink
                    
            -- toggle enable flag for target plugin
            EnablePlugin(id, not GetPluginInfo (id, 17))
            
            -- grey out if disabled now
            if not GetPluginInfo (id, 17) then 
               WindowFilter (win, x1, y1, x2, y2, 8, .4)
            end  -- if
  
            end,  -- function

  },   -- end of button 1

   -- button 2
 {
  icon = "bubble_32.png",
  tooltip = "Spell Practice",
  target_plugin = "656eeab9f4fe9bd89d066e25",
  script = function (n) 
            
            local id = buttons [n].target_plugin
            
            local f = frames [n]  -- where is image?
            local x1, y1, x2, y2 = f.x1, f.y1, f.x2, f.y2
            
            -- redraw the image
            WindowDrawImage(win, n, 
                    x1 + 1, y1 + 1,   -- left, top
                    x2 - 1, y2 - 1,  -- right, bottom
                    2)  -- mode - stretch or shrink
                    
            -- toggle enable flag for target plugin
            EnablePlugin(id, not GetPluginInfo (id, 17))
            
            -- grey out if disabled now
            if not GetPluginInfo (id, 17) then 
               WindowFilter (win, x1, y1, x2, y2, 8, .4)
            end  -- if
  
            end,  -- function

  },   -- end of button 2

   -- button 3
 {
  icon = "block_32.png",
  tooltip = "Crafting Omit",
  target_plugin = "157dce098adaa8ceebcbfc88",
  script = function (n) 
            
            local id = buttons [n].target_plugin
            
            local f = frames [n]  -- where is image?
            local x1, y1, x2, y2 = f.x1, f.y1, f.x2, f.y2
            
            -- redraw the image
            WindowDrawImage(win, n, 
                    x1 + 1, y1 + 1,   -- left, top
                    x2 - 1, y2 - 1,  -- right, bottom
                    2)  -- mode - stretch or shrink
                    
            -- toggle enable flag for target plugin
            EnablePlugin(id, not GetPluginInfo (id, 17))
            
            -- grey out if disabled now
            if not GetPluginInfo (id, 17) then 
               WindowFilter (win, x1, y1, x2, y2, 8, .4)
            end  -- if
			
            end,  -- function

  },   -- end of button 3

  
 --> add more buttons here
 
  
} -- end of buttons table


Thanks again Nick!
[Go to top] top

Posted by LupusFatalis   (154 posts)  [Biography] bio
Date Reply #16 on Tue 16 Jun 2009 05:22 AM (UTC)  quote  ]
Message
Oh, I found another spot it won't work, I think. When the plugins are enabled/disabled in other means. Not necessarily by the user, but by the plugin itself. I was thinking maybe putting a heartbeat function in, like you did in the script. But is there a way to reference the id from the buttons rather than manually checking them? etc...
[Go to top] top

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Reply #17 on Tue 16 Jun 2009 07:05 AM (UTC)  quote  ]
Message
Did you use the plugin further down that page? The version 2.0 one?

As for the heartbeat, you probably need a timer that fires every second, and in that, loop through every button (like when the buttons are loaded) and draws the image appropriately.


- Nick Gammon

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

Posted by LupusFatalis   (154 posts)  [Biography] bio
Date Reply #18 on Tue 16 Jun 2009 07:13 AM (UTC)  quote  ]
Message
This isn't the latest and greatest: http://www.gammon.com.au/forum/?id=9359 ?
[Go to top] top

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Reply #19 on Tue 16 Jun 2009 07:43 AM (UTC)  quote  ]
Message
When I asked which plugin you were working on and you replied:

Quote:

Oh, I'm working on the IconBar plugin.


I released 3 or 4 versions of that, which is why I asked.

In page 1 of this thread I mentioned http://www.gammon.com.au/forum/?id=9280 which has versions 1 and 2 of the plugin, but you are using http://www.gammon.com.au/forum/?id=9359 which is indeed later, but has version 4 of the plugin in it.

Since you are using the latest, greatest version, you also need to add a bit of code to the cooldowns section, which also draws the icon.

In the function SetCooldown, after the lines:


  if max > 0 then
    percent = (amount or 0) / max 
  else
    percent = 0  -- don't divide by zero!
  end -- if
  
  -- reload the image
  if WindowDrawImage(win, n, 
                  x1, y1,   -- left, top
                  x2, y2,  -- right, bottom
                  2)  -- mode - stretch or shrink
    ~= error_code.eOK then
    WindowRectOp (win, 2, x1, y1,   -- left, top
                  x2, y2,  -- right, bottom
                  BACKGROUND_COLOUR)
  end


Add:

           
  if buttons [n].target_plugin then                    
    -- grey out if disabled now
    if not GetPluginInfo (buttons [n].target_plugin, 17) then 
       WindowFilter (win, x1, y1, x2, y2, 8, .4)
    end  -- if
  end -- if



- Nick Gammon

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

Posted by LupusFatalis   (154 posts)  [Biography] bio
Date Reply #20 on Tue 16 Jun 2009 12:54 PM (UTC)  quote  ]

Amended on Tue 16 Jun 2009 12:55 PM (UTC) by LupusFatalis

Message
Ok, got it working. And I duplicated some of your code and now have a working heartbeat, check it out!

In the timers section:
  <timer second="1.00" 
         enabled="y" 
         script="heartbeat"
         >
  </timer>

And later in the script:
function heartbeat (timername)
  for n, v in ipairs (buttons) do

    if v.icon then
      if WindowLoadImage (win, n, GetInfo (66) .. v.icon) ~= error_code.eOK then
          DoAfterSpecial (1, string.format ([[
              ColourNote ("white", "red", "Could not load image '%s'")]], 
                          string.gsub (GetInfo (66) .. v.icon, '\', '\\')),
                          sendto.script)
      end -- if
    end -- if icon specified
       
    local x1, y1, x2, y2

    -- where to draw the icon
    if horizontal then
      x1, y1 = (n - 1) * (ICON_SIZE + OFFSET) + OFFSET, OFFSET
      x2, y2 = n * (ICON_SIZE + OFFSET), ICON_SIZE + OFFSET
    else
      x1, y1 = OFFSET, (n - 1) * (ICON_SIZE + OFFSET) + OFFSET
      x2, y2 = ICON_SIZE + OFFSET, n * (ICON_SIZE + OFFSET)
    end -- if
        
    -- draw the image
    WindowDrawImage(win, n, 
                    x1, y1,   -- left, top
                    x2, y2,  -- right, bottom
                    2)  -- mode - stretch or shrink
					
	if v.target_plugin then                    
      -- grey out if disabled now
      if not GetPluginInfo (v.target_plugin, 17) then 
         WindowFilter (win, x1, y1, x2, y2, 8, .4)
      end  -- if
    end -- if
  end --  for each world
end -- heartbeat
[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.


5,852 views.

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]