Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="iso-8859-1" ?>
- <!DOCTYPE muclient>
- <!-- Saved on Thursday, July 05, 2012, 1:04 AM -->
- <!-- MuClient version 4.73 -->
- <muclient>
- <plugin name="LotJStarMap" author="@Johnson" id="4a3763458731212345123bac" language="Lua" purpose="Star System Map" save_state="y" requires="4.73" version="1.0">
- <description trim="y">
- <![CDATA[
- Type "hypmap" to find starsystems and plot on map.
- Type "hidemap" to remove map window.
- ]]>
- </description>
- </plugin>
- <!-- Get our standard constants -->
- <include name="constants.lua" />
- <!-- Triggers -->
- <triggers>
- <trigger name="systemCapture" script="storeSystem" match="^(.*)\( (.*)\, (.*) \)$" regexp="y" group="StarCap" omit_from_log="y" omit_from_output="y" sequence="100"></trigger>
- <trigger name="starsFailed" script="toggleOff" match="^You must hold a datapad to do this\.$" regexp="y" group="StarCap" sequence="100"></trigger>
- <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>
- </triggers>
- <!-- Aliases -->
- <aliases>
- <alias name="initCommand" script="findStars" match="^hypmap$" enabled="y" regexp="y" group="LotJStarMap" sequence="100"></alias>
- <alias name="removeWindow" script="destroyWindow" match="^hidemap$" enabled="y" regexp="y" group="LotJStarMap" sequence="100"></alias>
- </aliases>
- <!-- Script -->
- <script>
- <![CDATA[
- require "movewindow"
- win = "galaxy_map_" .. GetPluginID() -- unique window name
- systems = {}
- system = { "", 0, 0 }
- font = "f"
- function findStars(name, list, args)
- Send("stars")
- Send("show")
- toggleOn()
- end
- function toggleOn(name, list, args)
- EnableTriggerGroup("StarCap", true)
- WindowCreate (win, 0, 0, 800, 600, miniwin.pos_center_all, 0, ColourNameToRGB("black")) -- create window
- WindowFont (win, font, "Courier", 10, true, false, false, false) -- define font
- end
- function storeSystem(name, list, args)
- if (args[1] and args[2] and args[3]) then
- system[1] = Trim(args[1])
- system[2] = tonumber(args[2])
- system[3] = tonumber(args[3])
- if (#systems == 0) then
- table.insert(systems, 1, system)
- else
- table.insert(systems, system)
- end
- system = { "", 0, 0 }
- end
- end
- function toggleOff(name, list, args)
- EnableTriggerGroup("StarCap", false)
- end
- function createWindow(name, list, args)
- toggleOff()
- local maxX = 0
- local maxY = 0
- for i=1,#systems,1 do
- local sys = systems[i]
- if (math.abs(sys[2]) > maxX) then
- maxX = math.abs(sys[2])
- end
- if (math.abs(sys[3]) > maxY) then
- maxY = math.abs(sys[3])
- end
- end
- for i=1,#systems,1 do
- local sys = systems[i]
- local x = (( sys[2] / (maxX + 10)) * 400) + 400 -- scale X coordinate
- local y = 300 - ((( sys[3] / (maxY + 10)) * 300)) -- scale Y coordinate
- WindowText (win, "f", sys[1], -- text
- x+5, y+5, 0, 0, -- rectangle
- ColourNameToRGB ("white"), -- colour
- false) -- not Unicode
- WindowCircleOp (win, miniwin.circle_ellipse, -- circle
- x, y, x+5, y+5, -- Left, Top, Right, Bottom
- ColourNameToRGB("blue"), miniwin.pen_solid, 1, -- pen width 1
- ColourNameToRGB("blue"), miniwin.brush_solid) -- brush
- end
- -- draw border
- WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
- -- add the drag handler so they can move the window around
- local font_height = WindowFontInfo (win, font, 1)
- movewindow.add_drag_handler (win, 0, 0, 0, font_height)
- -- heading line
- WindowText (win, font, "Galaxy Map", 5, 5, 0, 0, ColourNameToRGB "white")
- WindowShow (win, true) -- show it
- end
- function destroyWindow(name, list, args)
- systems = {}
- system = { "", 0, 0 }
- WindowDelete(win)
- end
- function OnPluginInstall ()
- -- install the window movement handler, get back the window position
- windowinfo = movewindow.install (win, 6) -- default to 6 (on top right)
- -- make window so I can grab the font info
- WindowCreate (win, 0, 0, 0, 0, 1, 0, 0)
- -- add the font
- WindowFont (win, font, "Courier", 10)
- end -- OnPluginInstall
- function OnPluginSaveState ()
- -- save window current location for next time
- movewindow.save_state (win)
- end -- function OnPluginSaveState
- ]]>
- </script>
- </muclient>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement