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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Miniwindow plugin - campaign tracker for Aardwolf
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Miniwindow plugin - campaign tracker for Aardwolf

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


Pages: 1 2  

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Sun 27 Jul 2008 12:26 AM (UTC)

Amended on Mon 28 Jul 2008 01:04 AM (UTC) by Nick Gammon

Message
The plugin below illustrates using the new miniwindows concept in a plugin.

Miniwindows were released in version 4.34, see here for a copy:

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

This plugin tracks your current campaign. Type "cp check" to get it to capture the campaign data.

Its design is similar to the quest tracker described here:

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

To use, copy between the lines, and save as Aardwolf_Campaign_Noter.xml in your Plugins directory, and then use File -> Plugins to install it.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, July 15, 2008, 11:06 AM -->
<!-- MuClient version 4.33 -->

<!-- Plugin "Aardwolf_Campaign_Noter" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Aardwolf_Campaign_Noter_v2"
   author="Nick Gammon"
   id="23c3c91af0a26790c625f5d1"
   language="Lua"
   purpose="Shows remaining campaign objectives"
   date_written="2008-07-22"
   requires="4.34"
   version="1.0"
   save_state="y"
   >
<description trim="y">
<![CDATA[
Shows outstanding campaign objectives.

To activate, type: cp check
]]>
</description>

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   match="You have * to finish this campaign."
   name="cp_time"
   script="cp_time"
   sequence="100"
  >
  </trigger>
  <trigger
   match="^You still have to kill \* (.*?)$"
   name="campaign_item"
   script="campaign_item"
   sequence="100"
   regexp="y"
  >
  </trigger>
  
 <trigger
   enabled="y"
   match="Congratulations, that was one of your CAMPAIGN mobs!"
   send_to="10"
   sequence="100"
  >
  <send>cp check</send>
  </trigger>

 <trigger
   enabled="y"
   match="CONGRATULATIONS! You have completed your campaign."
   sequence="100"
   script="campaign_done"
  >
  </trigger>


</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   name="cp_check"
   script="cp_check"
   match="^(cp|campaign) check$"
   enabled="y"
   regexp="y"
   sequence="100"
  >
  <send>cp check</send>
  </alias>
</aliases>


<!--  Timers  -->


<timers>
  <timer 
      script="show_campaign_text" 
      enabled="y" 
      second="30.00" 
      >
  </timer>
</timers>


<!--  Script  -->


<script>
<![CDATA[

require "commas"

background_colour = 0xE7FFFF
text_colour = 0x000000
heading_colour = 0x800080
time_colour = 0x82004B

campaign_info = {}
 
function capitalize (s)
  return string.sub (s, 1, 1):upper () .. string.sub (s, 2):lower ()
end -- capitalize 

function campaign_item (name, line, wildcards)
  local text =  wildcards [1]
  text = string.sub (text, 1, 1):upper () .. string.sub (text, 2)
  table.insert (campaign_info, text)
  max_width = math.max (max_width, WindowTextWidth (win, font_id, text))
end -- campaign_item

function campaign_done (name, line, wildcards)
  Send "score"
  WindowShow (win, false)
  campaign_info = {}
end -- campaign_done

function Display_Line (i, text, id, colour)

local left = 5
local top =  (i * font_height) - font_height

  WindowText (win, id, text, left, top, 0, 0, colour)

end -- Display_Line

function show_campaign_text ()

  -- do nothing if no campaign
  if #campaign_info == 0 or when_required == nil then
    return
  end -- if

  -- recreate the window the correct size
  check (WindowCreate (win, 
                 0, 0,   -- left, top (auto-positions)
                 max_width + 10,     -- width
                 (#campaign_info + 2)   * font_height + 5,  -- height
                 7,       -- auto-position: top middle
                 0,  -- flags
                 0xE7FFFF) )
 
  -- heading
  local text = "Current campaign. You need to kill:"
  max_width = math.max (max_width, WindowTextWidth (win, font_id, text))
  Display_Line (1, text, font_id, heading_colour)

  -- list of mobs
  for i, v in ipairs (campaign_info) do
    Display_Line (i + 1, v, font_id, text_colour)
  end -- for
  
  -- how long to go
  local time_to_go = when_required - os.time ()
  
  if time_to_go < 0 then
    return
  end -- if
  
  text = string.format ("Time to go: %s", convert_time (time_to_go))
  max_width = math.max (max_width, WindowTextWidth (win, font_id, text))
  Display_Line (#campaign_info + 2, text, font_id, time_colour)
    
  WindowShow (win, true)  
end -- show_campaign_text

function cp_time (name, line, wildcards)
  local text = wildcards [1]
    
  -- work out when campaign ends
  
  when_required = os.time ()
  
  local days = string.match (text, "(%d+) days?")
  if days then
    when_required = when_required + tonumber (days) * 60 * 60 * 24
  end -- some days left
  
  local hours = string.match (text, "(%d+) hours?")  
  if hours then
    when_required = when_required + tonumber (hours) * 60 * 60
  end -- some days left

  local minutes = string.match (text, "(%d+) minutes?")  
  if minutes then
    when_required = when_required + tonumber (minutes) * 60
  end -- some days left

  
  check (EnableTrigger ("campaign_item", false))
  check (EnableTrigger ("cp_time", false))

  show_campaign_text ()

end -- cp_time

function cp_check( name, line, wildcards)
  check (EnableTrigger ("campaign_item", true))
  check (EnableTrigger ("cp_time", true))
  campaign_info = {}
  max_width = 0
  
end -- cp_check


function OnPluginInstall ()
  
  win = GetPluginID ()
  font_id = "fn"
  
  font_name = "Comic Sans MS"    -- the actual font
  
  -- make window so I can grab the font info
  check (WindowCreate (win, 
                 0, 0, 1, 1,  
                 1,   -- irrelevant
                 0, 
                 background_colour) )

  check (WindowFont (win, font_id, font_name, 8, false, false, false, false, 0, 0))  -- normal  
  font_height = WindowFontInfo (win, font_id, 1)  -- height
end -- OnPluginInstall

function OnPluginDisable ()
  WindowShow (win, false)
end -- OnPluginDisable

]]>
</script>

</muclient>

- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 27 Jul 2008 12:31 AM (UTC)
Message

Example of it in operation:


- Nick Gammon

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

Posted by Bevern   (9 posts)  [Biography] bio
Date Reply #2 on Wed 30 Jul 2008 01:47 AM (UTC)
Message
Very nice, is there a way to hide the mini window without removing the plugin completely (while a campaign isn't finished)?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 30 Jul 2008 05:37 AM (UTC)
Message
These are still a bit of a work in progress. Something like the two aliases below should do it, although I haven't tested them.

Copy between the lines and paste before this line:


<!--  Script  -->



Two aliases here:


<aliases>
  <alias
   match="hide_campaign"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>WindowShow (win, false)</send>
  </alias>

  <alias
   match="show_campaign"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>WindowShow (win, true)</send>
  </alias>
</aliases>



- Nick Gammon

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

Posted by Imalish   (2 posts)  [Biography] bio
Date Reply #4 on Sat 17 Jan 2009 10:12 PM (UTC)
Message
Would there be a way to get the cp information output into a separate world window instead of an overlapping 'window'.

I ask this because font size vs screen size with this little window causes a significant amount of text to be covered up while its active.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sat 17 Jan 2009 11:16 PM (UTC)
Message
Where would you put this extra window that doesn't take up space? Just resize the main window a bit so that the tracker window moves to the right, and doesn't cover up anything.

- Nick Gammon

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

Posted by Imalish   (2 posts)  [Biography] bio
Date Reply #6 on Sun 18 Jan 2009 01:41 AM (UTC)
Message
unfortunately increasing the size of my main window will result in covering up all the other windows that i use constantly (spellup monitor,status,map and chat catcher)

my idea is that with the targets in a seperate window i can have it up over the other windows for the few moments it takes me to figure out where im running to next, then minimize it or send it behind the other windows ... no need for the window to be up and visible once i get into the appropriate zone.
[Go to top] top

Posted by Jennkei   (7 posts)  [Biography] bio
Date Reply #7 on Thu 19 Feb 2009 12:52 AM (UTC)

Amended on Thu 19 Feb 2009 02:12 AM (UTC) by Jennkei

Message
Thank you very much for this, Nick! Using it and loving it.

The aliases work, but why do the windows appear again after each tick? o.O

I've been wanting something like this for gquests for a long time now -- have always been copying to notepad. So I tried modifying this script...e.g.

<triggers>
  <trigger
   match="^You still have to kill (.*?) \* (.*?)$"
   name="gq_item"
   script="gq_item"
   sequence="100"
   regexp="y"
  >
  </trigger>


Unfortunately, didn't really seem to work..the trigger for gq check would fire, but that's about it. -wry- Ah well, not pro enough to wrestle with the code. :(
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Thu 19 Feb 2009 02:58 AM (UTC)
Message
Quote:

unfortunately increasing the size of my main window will result in covering up all the other windows that i use constantly


My original campaign tracker sent to a notepad window. Here it is:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, July 15, 2008, 11:06 AM -->
<!-- MuClient version 4.33 -->

<!-- Plugin "Aardwolf_Campaign_Noter" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Aardwolf_Campaign_Noter"
   author="Nick Gammon"
   id="2bfb7e23fb504ae4e55f0ed6"
   language="Lua"
   purpose="Shows remaining campaign objectives"
   date_written="2008-07-15 11:04:43"
   requires="4.33"
   version="1.0"
   save_state="y"
   >
<description trim="y">
<![CDATA[
Shows outstanding campaign objectives.

To activate, type: cp check
]]>
</description>

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   match="You have * left to finish this campaign."
   name="cp_time"
   script="cp_time"
   sequence="100"
  >
  </trigger>
  <trigger
   match="You still have to kill *"
   name="campaign_item"
   script="campaign_item"
   sequence="100"
  >
  </trigger>
  
 <trigger
   enabled="y"
   match="Congratulations, that was one of your CAMPAIGN mobs!"
   send_to="10"
   sequence="100"
  >
  <send>cp check</send>
  </trigger>

 <trigger
   enabled="y"
   match="CONGRATULATIONS! You have completed your campaign."
   sequence="100"
   script="campaign_done"
  >
  </trigger>


</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   name="cp_check"
   script="cp_check"
   match="^(cp|campaign) check$"
   enabled="y"
   regexp="y"
   sequence="100"
  >
  <send>cp check</send>
  </alias>
</aliases>

<!--  Timers  -->

<timers>
  <timer script="get_notepad_position" 
         enabled="y" 
         second="10.00" 
         active_closed="y" >

  </timer>
</timers>

<!--  Script  -->


<script>
<![CDATA[

require "serialize"

pos = {}

function get_notepad_position (name)
  local newpos = GetNotepadWindowPosition ("Campaign")
  pos = newpos or pos
  
  if next (pos) then
    Left, Top, Width, Height = pos.left, pos.top, pos.width, pos.height
  end -- if 
end -- get_notepad_position

-- notepad position
Left, Top, Width, Height = 500, 200, 600, 600
MenuSize = 50

campaign_info = {}
 
function campaign_item (name, line, wildcards)
  table.insert (campaign_info, line)
end -- campaign_item

function campaign_done (name, line, wildcards)
  Send "score"
  CloseNotepad ("Campaign", false)
end -- campaign_done

function cp_time (name, line, wildcards)

  table.insert (campaign_info, line)
  
  check (EnableTrigger ("campaign_item", false))
  check (EnableTrigger ("cp_time", false))

  CloseNotepad ("Campaign", false)
  ReplaceNotepad ("Campaign", table.concat (campaign_info, "\r\n"))
  NotepadColour ("Campaign", "black", "#FFFFE7")
  NotepadSaveMethod ("Campaign", 2)  -- don't try to save
  
  local lines = #campaign_info + 1
  
  if lines < 40 then
    MoveNotepadWindow ("Campaign", Left, Top, Width, GetInfo (214) * lines + MenuSize)  
  else
    MoveNotepadWindow("Campaign", Left, Top, Width, Height)
  end -- if
  
  ActivateNotepad "Campaign"
  
  Activate ()
  
  NotepadReadOnly ("Campaign")
  
end -- cp_time

function cp_check( name, line, wildcards)
  check (EnableTrigger ("campaign_item", true))
  check (EnableTrigger ("cp_time", true))
  campaign_info = {}
  
end -- cp_check

function OnPluginSaveState ()
  get_notepad_position ()
  SetVariable ("pos", "pos = " .. serialize.save_simple (pos))
end -- function OnPluginSaveState

function OnPluginInstall ()
  assert (loadstring (GetVariable ("pos") or "")) ()
  
  if next (pos) then
    Left, Top, Width, Height = pos.left, pos.top, pos.width, pos.height
  end -- table not empty
  
end -- OnPluginInstall

]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="Aardwolf_Campaign_Noter:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
function OnHelp ()
  world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script> 

</muclient>


Not sure how well it works now, but it could be a start for you to look at.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Thu 19 Feb 2009 03:02 AM (UTC)
Message
Quote:

The aliases work, but why do the windows appear again after each tick? o.O


It seems I didn't think it through. :O

Give the timer a name, like this:


<timers>
  <timer 
      script="show_campaign_text" 
      enabled="y" 
      second="30.00"
      name="show_campaign_text" 
      >
  </timer>
</timers>


Modify the aliases to disable/enable the timer:


<aliases>
  <alias
   match="hide_campaign"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
WindowShow (win, false)
EnableTimer ("show_campaign_text", false)
</send>
  </alias>

  <alias
   match="show_campaign"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
WindowShow (win, true)
EnableTimer ("show_campaign_text", true)
</send>
  </alias>
</aliases>




- Nick Gammon

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

Posted by Jennkei   (7 posts)  [Biography] bio
Date Reply #10 on Thu 19 Feb 2009 03:44 AM (UTC)

Amended on Thu 19 Feb 2009 03:50 AM (UTC) by Jennkei

Message
Hiding works beautifully now. Thank you so much, Nick! :)

If it's not too much trouble and you're free, could you possibly help me have a look at what's wrong with my replace-cp-with-gq version, please..? It's alright if you aren't, just thought I'd ask anyway. :D

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- From Aardwolf_Campaign_Noter_v2 by Nick Gammon -->
<!-- Saved on Tuesday, July 15, 2008, 11:06 AM -->
<!-- MuClient version 4.33 -->

<!-- Plugin "Aardwolf_Gq_Noter" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Aardwolf_gq_Noter"
   author="Nick Gammon -modified-"
   id="23c3c91af0a26790c625f5d2"
   language="Lua"
   purpose="Shows remaining gq objectives"
   date_written="2008-07-22"
   requires="4.34"
   version="1.0"
   save_state="y"
   >
<description trim="y">
<![CDATA[
Shows outstanding gq objectives.

]]>
</description>

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   match="^You still have to kill (.*?) \* (.*?)$"
   name="gq_item"
   script="gq_item"
   sequence="100"
   regexp="y"
  >
  </trigger>
  
 <trigger
   enabled="y"
   match="Congratulations, that was one of the GLOBAL QUEST mobs!"
   send_to="10"
   sequence="100"
  >
  <send>gq check</send>
  </trigger>

 <trigger
   enabled="y"
   match="Global Quest: The global quest has been won by"
   sequence="100"
   script="gq_done"
  >
  </trigger>

</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   name="gq_check"
   script="gq_check"
   match="^(gq|gquest) check$"
   enabled="y"
   regexp="y"
   sequence="100"
  >
  <send>gq check</send>
  </alias>
</aliases>


<!--  Script  -->


<script>
<![CDATA[

require "commas"

background_colour = 0xE7FFFF
text_colour = 0x000000
heading_colour = 0x800080
time_colour = 0x82004B

gq_info = {}
 
function capitalize (s)
  return string.sub (s, 1, 1):upper () .. string.sub (s, 2):lower ()
end -- capitalize 

function gq_item (name, line, wildcards)
  local text =  wildcards [1]
  text = string.sub (text, 1, 1):upper () .. string.sub (text, 2)
  table.insert (gq_info, text)
  max_width = math.max (max_width, WindowTextWidth (global, font_id, text))
end -- gq_item

function gq_done (name, line, wildcards)
  WindowShow (global, false)
  gq_info = {}
end -- gq_done

function Display_Line (i, text, id, colour)

local right = 5
local top =  (i * font_height) - font_height

  WindowText (global, id, text, left, top, 0, 0, colour)

end -- Display_Line

function show_gq_text ()

  -- do nothing if no gq
  if #gq_info == 0 or when_required == nil then
    return
  end -- if

  -- recreate the Window the correct size
  check (WindowCreate (global, 
                 0, 0,   -- left, top (auto-positions)
                 max_width + 10,     -- width
                 (#gq_info + 2)   * font_height + 5,  -- height
                 7,       -- auto-position: top middle
                 0,  -- flags
                 0xE7FFFF) )
 
  -- heading
  local text = "Current gq. You need to kill:"
  max_width = math.max (max_width, WindowTextWidth (global, font_id, text))
  Display_Line (1, text, font_id, heading_colour)

  -- list of mobs
  for i, v in ipairs (gq_info) do
    Display_Line (i + 1, v, font_id, text_colour)
  end -- for
     
  WindowShow (global, true)  
end -- show_gq_text

   
  
function gq_check( name, line, wildcards)
  check (EnableTrigger ("gq_item", true))
  gq_info = {}
  max_width = 0
  
end -- gq_check


function OnPluginInstall ()
  global = GetPluginID ()
  font_id = "fn"
  
  font_name = "Comic Sans MS"    -- the actual font
  
  -- make window so I can grab the font info
  check (WindowCreate (global, 
                 0, 0, 1, 1,  
                 1,   -- irrelevant
                 0, 
                 background_colour) )

  check (WindowFont (global, font_id, font_name, 8, false, false, false, false, 0, 0))  -- normal  
  font_height = WindowFontInfo (global, font_id, 1)  -- height
end -- OnPluginInstall

function OnPluginDisable ()
  WindowShow (global, false)
end -- OnPluginDisable

]]>
</script>

</muclient>
[Go to top] top

Posted by Aardhabit   (4 posts)  [Biography] bio
Date Reply #11 on Tue 22 Sep 2009 06:29 PM (UTC)
Message
Has anyone out there successfully made a gq mob tracker similar to the cp mob tracker and willing to share it? I would maybe not be eternally grateful, but I would be grateful for a long, long time.
[Go to top] top

Posted by Bast   (77 posts)  [Biography] bio
Date Reply #12 on Tue 22 Sep 2009 07:50 PM (UTC)
Message
I have one at http://code.google.com/p/bastmush/

Bast

Bast

Scripts: http://bastmush.googlecode.com
[Go to top] top

Posted by Aardhabit   (4 posts)  [Biography] bio
Date Reply #13 on Tue 22 Sep 2009 08:50 PM (UTC)
Message
Thanks very much! :-) If I could only get by the parsing errors, I'd be delighted!
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Reply #14 on Tue 22 Sep 2009 11:42 PM (UTC)
Message
Post the errors.
[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.


40,611 views.

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

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 FutureQuest]