Advertisement
Guest User

Friends_List.xml

a guest
Jul 26th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.16 KB | None | 0 0
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE muclient>
  3. <muclient>
  4. <plugin
  5.    name="Friends_List"
  6.    author="Fumino"
  7.    id="8a1bb56bff11f9cdd21d98e3"
  8.    language="Lua"
  9.    purpose="Friends List"
  10.    date_written="2016-07-23 00:10:31"
  11.    requires="4.51"
  12.    version="1.0"
  13.    save_state="y"
  14.    >
  15. <description trim="y">
  16. </description>
  17. </plugin>
  18.  
  19. <triggers>
  20.  <trigger
  21.   enabled="n"
  22.   keep_evaluating="y"
  23.   match="*"
  24.   name="whoRead"
  25.   script="who_read"
  26.   sequence="100">
  27.  </trigger>
  28. </triggers>
  29.  
  30. <aliases>
  31.  <alias
  32.   match="add friend *"
  33.   send_to="12"
  34.   enabled="y"
  35.   sequence="100">
  36.   <send>who = "%1"
  37.     who_addF(who)</send>
  38.  </alias>
  39.  
  40.  <alias
  41.   match="remove friend *"
  42.   send_to="12"
  43.   enabled="y"
  44.   sequence="100">
  45.   <send>who = "%1"
  46.     who_remF(who)</send>
  47.  </alias>
  48.  
  49.  <alias
  50.   match="add enemy *"
  51.   send_to="12"
  52.   enabled="y"
  53.   sequence="100">
  54.   <send>who = "%1"
  55.     who_addE(who)</send>
  56.  </alias>
  57.  
  58.  <alias
  59.   match="remove enemy *"
  60.   send_to="12"
  61.   enabled="y"
  62.   sequence="100">
  63.   <send>who = "%1"
  64.     who_remE(who)</send>
  65.  </alias>
  66.  
  67.  <alias
  68.   script="who_list"
  69.   match="who"
  70.   enabled="y"
  71.   sequence="100">
  72.  </alias>
  73.  
  74.  <alias
  75.   script="whoToggle"
  76.   match="who hud *"
  77.   enabled="y"
  78.   sequence="100">
  79.  </alias>
  80.  
  81.  <alias
  82.   script="who_help"
  83.   match="who help"
  84.   enabled="y"
  85.   sequence="100">
  86.  </alias>
  87.  
  88.  <alias
  89.   script="showFriends"
  90.   match="show friends"
  91.   enabled="y"
  92.   sequence="100">
  93.  </alias>
  94.  
  95.  <alias
  96.   script="showFriends"
  97.   match="view friends"
  98.   enabled="y"
  99.   sequence="100">
  100.  </alias>
  101.  
  102.  <alias
  103.   script="showEnemies"
  104.   match="show enemies"
  105.   enabled="y"
  106.   sequence="100">
  107.  </alias>
  108.  
  109.  <alias
  110.   script="showEnemies"
  111.   match="view enemies"
  112.   enabled="y"
  113.   sequence="100">
  114.  </alias>
  115.  
  116.  <alias
  117.   script="clearFriends"
  118.   match="clear friends list"
  119.   enabled="y"
  120.   sequence="100">
  121.  </alias>
  122.  
  123.  <alias
  124.   script="clearEnemies"
  125.   match="clear enemies list"
  126.   enabled="y"
  127.   sequence="100">
  128.  </alias>
  129. </aliases>
  130.  
  131. <script>
  132.  <![CDATA[
  133.     function OnPluginInstall ()
  134.         require "pairsbykeys"
  135.         PLUGIN_VERSION = GetPluginInfo(GetPluginID(), 19)
  136.         if PLUGIN_VERSION == 1 then
  137.             PLUGIN_VERSION = 1 .. "." .. 0
  138.         end -- PLUGIN_VERSION
  139.         PLUGIN_NAME = GetPluginInfo(GetPluginID(), 1)
  140.         wListStyles, wListRCN, wListRaces, wListClasses, wListNames = {}, {}, {}, {}, {}
  141.         if GetVariable("friendsC") == nil then
  142.             SetVariable("friendsC", ColourNameToRGB("steelblue"))
  143.         else
  144.             friendsC = GetVariable("friendsC")
  145.         end -- friendsC
  146.         if GetVariable("enemiesC") == nil then
  147.             SetVariable("enemiesC", ColourNameToRGB("red"))
  148.         else
  149.             enemiesC = GetVariable("enemiesC")
  150.         end -- enemiesC
  151.         who_hud = "who_hud"  -- Who List Heads-up Display Window
  152.          --if GetVariable("wHud_pos") == nil then
  153.             SetVariable("wHud_pos", "6")
  154.         --end -- default to top right corner if first run
  155.         -- Rebuild Friends & Enemies tables
  156.         require "serialize"
  157.         who_friends = {}
  158.         assert (loadstring (GetVariable ("who_friends") or "")) ()
  159.         who_enemies = {}
  160.         assert (loadstring (GetVariable ("who_enemies") or "")) ()
  161.         -- Dummy window to get font characteristics
  162.         WindowCreate (who_hud, 0, 0, 1, 1, 12, 2, 0x000000)
  163.         font = "f"
  164.         WindowFont (who_hud, font, "November", 10)
  165.         max_width = WindowTextWidth (who_hud, font, "W")
  166.         -- Display welcome message.
  167.         who_help ()
  168.     end -- function OnPluginInstall
  169.    
  170.     function OnPluginSaveState ()
  171.         SetVariable ("who_friends", serialize.save ("who_friends"))
  172.         SetVariable ("who_enemies", serialize.save ("who_enemies"))
  173.     end -- function OnPluginSaveState
  174.    
  175.     function OnPluginEnable ()
  176.         if GetVariable("wHudWin_Visi") == "true" then
  177.             WindowShow (who_hud, true)
  178.         else
  179.             SetVariable("wHudWin_Visi", "false")  -- in case first run and nil
  180.             WindowShow (who_hud, false)
  181.         end -- wHudWin_Visi
  182.     end -- function OnPluginEnable
  183.  
  184.     function OnPluginDisable ()
  185.         WindowShow (who_hud, false)
  186.     end -- function OnPluginDisable
  187.    
  188.     function OnPluginClose ()
  189.         if GetPluginInfo (GetPluginID(), 17) then
  190.             OnPluginDisable()
  191.         end -- if enabled
  192.     end -- function OnPluginClose
  193.  
  194.     ----/  Add a friend (who_addF)  /----
  195.     function who_addF (who)
  196.         who_friends [who] = true
  197.         print(who .. " has been added to the Friends List")
  198.         who_win ()
  199.     end -- function who_addF
  200.    
  201.     ----/  Remove a friend (who_remF)  /----
  202.     function who_remF (who)
  203.         who_friends [who] = nil
  204.         print(who .. " has been removed from the Friends List")
  205.         who_win ()
  206.     end -- function who_remF
  207.    
  208.     ----/  Add an enemy (who_addE)  /----
  209.     function who_addE (who)
  210.         who_enemies [who] = true
  211.         print(who .. " has been added to the Enemies List")
  212.         who_win ()
  213.     end -- function who_addE
  214.    
  215.     ----/  Remove an enemy (who_remE)  /----
  216.     function who_remE (who)
  217.         who_enemies [who] = nil
  218.         print(who .. " has been removed from the Enemies List")
  219.         who_win ()
  220.     end -- function who_remE
  221.    
  222.     ----/  Read & Store Who List  /----
  223.     function who_read (name, line, wildcards, styles)
  224.         -- Stop reading at first blank line
  225.         if string.match (line, "^$") then
  226.             EnableTrigger("whoRead", false)
  227.             if GetVariable("wHudWin_Visi") == "true" then
  228.                 who_win ()
  229.             end -- wHudWin_Visi
  230.         else
  231.             -- Matching only up to name
  232.             whoRCN = string.match (line, "^(.- %] %a+)")  -- Race Classes Name
  233.             if whoRCN == nil then
  234.                 whoRCN = line
  235.             end -- whoRCN
  236.             -- Matching each section out into own variables
  237.             whoRa = string.match(whoRCN, "^(%a+ .-)")  -- Race
  238.             whoCl = string.match(whoRCN, "^.-(%[.*%])")  -- Classes
  239.             whoNa = string.match(whoRCN, " (%a+)$")  -- Name
  240.             -- Storing the styles for text color
  241.             table.insert (wListStyles, styles)
  242.             -- Storing everything else
  243.             if whoRCN ~= nil then
  244.                 wListRCN [whoRCN] = true
  245.                 max_width = math.max (max_width, WindowTextWidth (who_hud, font, whoRCN))
  246.             end -- whoRCN
  247.             if whoRa ~= nil and whoCl ~= nil and whoNa ~= nil then
  248.                 wListRaces [whoRa] = true
  249.                 wListClasses [whoCl] = true
  250.                 wListNames [whoNa] = true
  251.             end -- check before adding into tables
  252.             -- work out max width
  253.         end -- string.match
  254.     end -- function who_read
  255.    
  256.     ----/  "who" alias script  /----
  257.     function who_list ()
  258.         -- Clear all tables
  259.         wListStyles, wListRCN, wListRaces, wListClasses, wListNames = {}, {}, {}, {}, {}
  260.         Send "who"
  261.         -- Start reading and storing every line
  262.         EnableTrigger("whoRead", true)
  263.     end -- function who_read
  264.    
  265.     ----/  Who List Heads-up Display Window  /----
  266.     function who_win ()
  267.         if GetVariable("wHudWin_Visi") == "true" then
  268.             local font_height = WindowFontInfo (who_hud, font, 1)
  269.             local wHud_width = max_width + 10
  270.             local wHud_height = font_height * (#wListRCN + 2) + 70
  271.             wHud_left, wHud_top = GetInfo(264) - wHud_width, 0
  272.             WindowCreate (who_hud, wHud_left, wHud_top, wHud_width + 20, wHud_height, 4, GetVariable("wHud_pos"), 0x000000)
  273.             --WindowCreate (who_hud, wHud_left, wHud_top, wHud_left, 300, 4, GetVariable("wHud_pos"), ColourNameToRGB("darkgreen"))
  274.         if wListStyles ~= nil then
  275.         local y = font_height * 2 + 5
  276.             for i, styles in ipairs (wListStyles) do
  277.                 local x = 3
  278.                 for _, style in ipairs (styles) do
  279.                         if style.text == string.match(style.text, "^(.*Total.*)") then
  280.                             x = x + WindowText (who_hud, font, style.text, 25, y + 1, 0, 0, ColourNameToRGB("gold"))
  281.                         else
  282.                             --/  Comparing Friends & Enemies list to current Who List and coloring accordingly  /--
  283.                             for k, v in pairs (wListNames) do
  284.                             for c, h in pairs (wListClasses) do
  285.                                 if who_friends [k] then
  286.                                     -- color friends if online
  287.                                         x = x + WindowText (who_hud, font, k, x, y + 15, 0, 0, friendsC)
  288.                                         WindowText (who_hud, font, c, 80, y + 15, 0, 0, friendsC)
  289.                                 elseif who_enemies [k] then
  290.                                     -- color enemies if online
  291.                                         x = x + WindowText (who_hud, font, whoNa, x, y + 15, 0, 0, enemiesC)
  292.                                         WindowText (who_hud, font, c, 80, y + 15, 0, 0, enemiesC)
  293.                                 else
  294.                                     x = x + WindowText (who_hud, font, k, x, y + 15, 0, 0, style.textcolour)
  295.                                     WindowText (who_hud, font, c, 80, y + 15, 0, 0, style.textcolour)
  296.                                 end -- enemy check names
  297.                             end -- for c, h in pairs (wListClasses)
  298.                             end -- for k, v in pairs (wListNames)
  299.                         y = y + font_height
  300.                         end -- total players online
  301.                 end -- for _, style in ipairs (styles)
  302.             end -- for i, styles in ipairs (wListStyles)
  303.         else
  304.             WindowText (who_hud, font, "Who List will show up here", 25, 1, 0, 0, ColourNameToRGB("gold"))
  305.         end -- wListStyles not nil
  306.         WindowShow (who_hud, true)
  307.         else
  308.             WindowShow (who_hud, false)
  309.         end -- wHudWin_Visi    
  310.     end -- function who_win
  311.    
  312.     function showFriends ()
  313.         if who_friends ~= nil then
  314.             ColourNote ("white", "", "--------------------------")
  315.             ColourNote ("steelblue", "", "      Friends List      ")
  316.             ColourNote ("white", "", "--------------------------")
  317.             for k, v in pairsByKeys (who_friends) do
  318.                 print (k)
  319.             end -- for
  320.         else
  321.             ColourNote ("red", "", "Friends list empty!")
  322.         end -- who_friends
  323.     end -- function showFriends
  324.    
  325.     function showEnemies ()
  326.         if who_enemies ~= nil then
  327.             ColourNote ("red", "", "--------------------------")
  328.             ColourNote ("orangered", "", "      Enemies List      ")
  329.             ColourNote ("red", "", "--------------------------")
  330.             for k, v in pairsByKeys (who_enemies) do
  331.                 print (k)
  332.             end -- for
  333.         else
  334.             ColourNote ("red", "", "Enemies list empty!")
  335.         end -- who_enemies
  336.     end -- function showEnemies
  337.    
  338.     function whoToggle (name, line, wildcards, styles)
  339.         if wildcards[1] == "on" then
  340.             SetVariable("wHudWin_Visi", "true")
  341.             who_list ()
  342.             who_win ()
  343.         elseif wildcards[1] == "off" then
  344.             SetVariable("wHudWin_Visi", "false")
  345.             who_win ()
  346.         else
  347.             ColourNote ("red", "", "Error! ", "silver", "", "commands are: ", "green", "", " who hud on ", "silver", "", "and ", "green", "", "who hud off")
  348.         end -- wildcard on|off
  349.     end -- function whoToggle
  350.    
  351.     function who_help ()
  352.         Note("")
  353.         ColourNote ("yellow", "", "            W", "goldenrod", "", "ho ", "silver", "", "List - ", "green", "", "Friends ", "white", "", "& ", "red", "", "Enemies ", "white", "", "Tracker v1.0")
  354.         ColourNote ("dodgerblue", "", "               Plugin ", "silver", "", "Version: ", "green", "", "v" .. PLUGIN_VERSION, "white", "", "  " .. PLUGIN_NAME)
  355.         Note("")
  356.         ColourNote ("lime", "", "[ WHO LIST HEADS-UP DISPLAY  ]")
  357.         Note("")
  358.         ColourNote ("steelblue", "", "To ", "silver", "", "Activate: ", "green", "", "who hud on")
  359.         ColourNote ("orangered", "", "To ", "silver", "", "Deactivate: ", "green", "", "who hud off")
  360.         Note("")
  361.         ColourNote ("steelblue", "", "[  FRIENDS  ]")
  362.         Note("")
  363.         ColourNote ("steelblue", "", "To ", "silver", "", "Add a Friend: ", "green", "", "add friend NAME")
  364.         ColourNote ("orangered", "", "To ", "silver", "", "Remove a Friend: ", "green", "", "remove friend NAME")
  365.         Note("")
  366.         ColourNote ("orangered", "", "[  FOES  ]")
  367.         Note("")
  368.         ColourNote ("steelblue", "", "To ", "silver", "", "Add an Enemy: ", "green", "", "add enemy NAME")
  369.         ColourNote ("orangered", "", "To ", "silver", "", "Remove an Enemy: ", "green", "", "remove enemy NAME")
  370.         Note("")
  371.         ColourNote ("white", "", "[  ", "orangered", "", "NAUGHTY  ", "white", "", " OR ", "steelblue", "", "  NICE ", "white", "", " ]")
  372.         Note("")
  373.         ColourNote ("steelblue", "", "To ", "silver", "", "View Friends List: ", "green", "", "show friends", "silver", "", " | ", "green", "", "view friends")
  374.         ColourNote ("orangered", "", "To ", "silver", "", "View Enemies List: ", "green", "", "show enemies", "silver", "", " | ", "green", "", "view enemies")
  375.         Note("")
  376.         ColourNote ("orange", "", "To ", "silver", "", "Clear Friends List: ", "green", "", "clear friends list")
  377.         ColourNote ("orange", "", "To ", "silver", "", "Clear Enemies List: ", "green", "", "clear enemies list")
  378.         Note("")
  379.         ColourNote ("white", "", "To view this welcome message again, type: ", "green", "", "who help", "white", "", " or view the readme file.")
  380.         Note("")
  381.     end -- function who_help
  382.    
  383.     function clearFriends ()
  384.         who_friends = {}
  385.         ColourNote ("steelblue", "", "Friends List has been cleared!")
  386.     end -- function clearFriends
  387.    
  388.     function clearEnemies ()
  389.         who_enemies = {}
  390.         ColourNote ("orangered", "", "Enemies List has been cleared!")
  391.     end -- function clearEnemies
  392.  
  393.  ]]>
  394. </script>
  395. </muclient>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement