Advertisement
Guest User

MUSHClient LotJ Hyperspace Map

a guest
Jul 5th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. <?xml version="1.0" encoding="iso-8859-1" ?>
  2. <!DOCTYPE muclient>
  3. <!-- Saved on Thursday, July 05, 2012, 1:04 AM -->
  4. <!-- MuClient version 4.73 -->
  5. <muclient>
  6. <plugin name="LotJStarMap" author="@Johnson" id="4a3763458731212345123bac" language="Lua" purpose="Star System Map" save_state="y" requires="4.73" version="1.0">
  7. <description trim="y">
  8. <![CDATA[
  9. Type "hypmap" to find starsystems and plot on map.
  10. Type "hidemap" to remove map window.
  11. ]]>
  12. </description>
  13. </plugin>
  14. <!-- Get our standard constants -->
  15. <include name="constants.lua" />
  16. <!-- Triggers -->
  17. <triggers>
  18. <trigger name="systemCapture" script="storeSystem" match="^(.*)\( (.*)\, (.*) \)$" regexp="y" group="StarCap" omit_from_log="y" omit_from_output="y" sequence="100"></trigger>
  19. <trigger name="starsFailed" script="toggleOff" match="^You must hold a datapad to do this\.$" regexp="y" group="StarCap" sequence="100"></trigger>
  20. <trigger name="systemCapDone" script="createWindow" match="^Show what to whom\?$" regexp="y" group="StarCap" omit_from_log="y" omit_from_output="y" sequence="100"></trigger>
  21.  
  22. </triggers>
  23. <!-- Aliases -->
  24. <aliases>
  25. <alias name="initCommand" script="findStars" match="^hypmap$" enabled="y" regexp="y" group="LotJStarMap" sequence="100"></alias>
  26. <alias name="removeWindow" script="destroyWindow" match="^hidemap$" enabled="y" regexp="y" group="LotJStarMap" sequence="100"></alias>
  27.  
  28. </aliases>
  29. <!-- Script -->
  30. <script>
  31. <![CDATA[
  32.  
  33. require "movewindow"
  34. win = "galaxy_map_" .. GetPluginID() -- unique window name
  35. systems = {}
  36. system = { "", 0, 0 }
  37. font = "f"
  38.  
  39.  
  40. function findStars(name, list, args)
  41. Send("stars")
  42. Send("show")
  43. toggleOn()
  44. end
  45.  
  46. function toggleOn(name, list, args)
  47. EnableTriggerGroup("StarCap", true)
  48. WindowCreate (win, 0, 0, 800, 600, miniwin.pos_center_all, 0, ColourNameToRGB("black")) -- create window
  49. WindowFont (win, font, "Courier", 10, true, false, false, false) -- define font
  50. end
  51.  
  52. function storeSystem(name, list, args)
  53. if (args[1] and args[2] and args[3]) then
  54. system[1] = Trim(args[1])
  55. system[2] = tonumber(args[2])
  56. system[3] = tonumber(args[3])
  57. if (#systems == 0) then
  58. table.insert(systems, 1, system)
  59. else
  60. table.insert(systems, system)
  61. end
  62. system = { "", 0, 0 }
  63. end
  64. end
  65.  
  66. function toggleOff(name, list, args)
  67. EnableTriggerGroup("StarCap", false)
  68. end
  69.  
  70.  
  71. function createWindow(name, list, args)
  72. toggleOff()
  73. local maxX = 0
  74. local maxY = 0
  75. for i=1,#systems,1 do
  76. local sys = systems[i]
  77. if (math.abs(sys[2]) > maxX) then
  78. maxX = math.abs(sys[2])
  79. end
  80. if (math.abs(sys[3]) > maxY) then
  81. maxY = math.abs(sys[3])
  82. end
  83. end
  84.  
  85.  
  86. for i=1,#systems,1 do
  87. local sys = systems[i]
  88. local x = (( sys[2] / (maxX + 10)) * 400) + 400 -- scale X coordinate
  89. local y = 300 - ((( sys[3] / (maxY + 10)) * 300)) -- scale Y coordinate
  90. WindowText (win, "f", sys[1], -- text
  91. x+5, y+5, 0, 0, -- rectangle
  92. ColourNameToRGB ("white"), -- colour
  93. false) -- not Unicode
  94.  
  95. WindowCircleOp (win, miniwin.circle_ellipse, -- circle
  96. x, y, x+5, y+5, -- Left, Top, Right, Bottom
  97. ColourNameToRGB("blue"), miniwin.pen_solid, 1, -- pen width 1
  98. ColourNameToRGB("blue"), miniwin.brush_solid) -- brush
  99.  
  100. end
  101.  
  102. -- draw border
  103. WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
  104.  
  105. -- add the drag handler so they can move the window around
  106. local font_height = WindowFontInfo (win, font, 1)
  107. movewindow.add_drag_handler (win, 0, 0, 0, font_height)
  108.  
  109. -- heading line
  110. WindowText (win, font, "Galaxy Map", 5, 5, 0, 0, ColourNameToRGB "white")
  111.  
  112.  
  113. WindowShow (win, true) -- show it
  114.  
  115. end
  116.  
  117. function destroyWindow(name, list, args)
  118. systems = {}
  119. system = { "", 0, 0 }
  120. WindowDelete(win)
  121. end
  122.  
  123.  
  124. function OnPluginInstall ()
  125.  
  126. -- install the window movement handler, get back the window position
  127. windowinfo = movewindow.install (win, 6) -- default to 6 (on top right)
  128.  
  129. -- make window so I can grab the font info
  130. WindowCreate (win, 0, 0, 0, 0, 1, 0, 0)
  131.  
  132. -- add the font
  133. WindowFont (win, font, "Courier", 10)
  134.  
  135. end -- OnPluginInstall
  136.  
  137. function OnPluginSaveState ()
  138. -- save window current location for next time
  139. movewindow.save_state (win)
  140. end -- function OnPluginSaveState
  141.  
  142.  
  143. ]]>
  144. </script>
  145. </muclient>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement