Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 83 additions & 59 deletions MapWindow.plugin/libraries/ppi.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
-- Semantic versioning: http://semver.org/
local __V_MAJOR, __V_MINOR, __V_PATCH = 1, 2, 4
local __V_MAJOR, __V_MINOR, __V_PATCH = 1, 3, 0
local __VERSION = string.format("%d.%d.%d", __V_MAJOR, __V_MINOR, __V_PATCH)

-- The module table's variable
local PPI
local PPI = {
-- Version identifiers
__V = __VERSION,
__V_MAJOR = __V_MAJOR,
__V_MINOR = __V_MINOR,
__V_PATCH = __V_PATCH,

-- More added later in the file
}

-- Contains a list of PPI proxies to other plugins.
-- Also contains private data for each PPI.
local PPI_list = {}

-- Loader callbacks (added in v1.3.0)
local loaders = {}

-- Local data for this plugin's PPI
local myID = GetPluginID()
local myPPI = {}
Expand Down Expand Up @@ -274,65 +285,78 @@ local PPI_meta = {
end,
}

-- The returned module table.
-- Declared (local) at the top of the file.
PPI = {
-- Version identifiers
__V = __VERSION,
__V_MAJOR = __V_MAJOR,
__V_MINOR = __V_MINOR,
__V_PATCH = __V_PATCH,

-- Given a value during execution of callbacks
PPI.CallerID = nil

-- Used to retreive a PPI for a specified plugin.
PPI.Load = function(id)
-- Is the plugin installed?
if not IsPluginInstalled(id) then
return nil, "not_installed"
-- Is the plugin enabled?
elseif not GetPluginInfo(id, 17) then
return nil, "not_enabled"
-- Does the plugin support PPI invocations?
elseif PluginSupports(id, invoke_msg) ~= 0 then
return nil, "no_ppi"
end

-- Given a value during execution of callbacks
CallerID = nil,


-- Used to retreive a PPI for a specified plugin.
Load = function(id)
-- Is the plugin installed?
if not IsPluginInstalled(id) then
return nil, "not_installed"
-- Is the plugin enabled?
elseif not GetPluginInfo(id, 17) then
return nil, "not_enabled"
-- Does the plugin support PPI invocations?
elseif PluginSupports(id, invoke_msg) ~= 0 then
return nil, "no_ppi"
end

-- Get the PPI record
local tbl = PPI_list[id]
local reloaded = true

-- Create one if there isn't one yet
if not tbl then
tbl = {
ppi = setmetatable({}, PPI_meta),
id = id,
thunks = {},
nonce = GetPluginInfo(id, 22),
}

PPI_list[id] = tbl
PPI_list[tbl.ppi] = id
-- If there is one, reload it if the plugin's nonce has changed.
elseif tbl.nonce ~= GetPluginInfo(id, 22) then
tbl.nonce = GetPluginInfo(id, 22)
tbl.thunks = {}
else
reloaded = false
end
-- Get the PPI record
local tbl = PPI_list[id]
local reloaded = true

-- Create one if there isn't one yet
if not tbl then
tbl = {
ppi = setmetatable({}, PPI_meta),
id = id,
thunks = {},
nonce = GetPluginInfo(id, 22),
}

return tbl.ppi, reloaded
end,
PPI_list[id] = tbl
PPI_list[tbl.ppi] = id
-- If there is one, reload it if the plugin's nonce has changed.
elseif tbl.nonce ~= GetPluginInfo(id, 22) then
tbl.nonce = GetPluginInfo(id, 22)
tbl.thunks = {}
else
reloaded = false
end

-- Used by a plugin to expose methods to other plugins
-- through its own PPI.
Expose = function(name, data)
-- Add the data to the exposed PPI
myPPI[name] = data or _G[name]
end,
}
return tbl.ppi, reloaded
end

-- Used by a plugin to expose methods to other plugins
-- through its own PPI.
PPI.Expose = function(name, data)
-- Add the data to the exposed PPI
myPPI[name] = data or _G[name]
end

PPI.OnLoad = function(id, on_success, on_failure)
loaders[id] = {
success=on_success,
failure=on_failure,
}
end

PPI.Refresh = function()
for id, callbacks in pairs(loaders) do
local iface, is_reloaded = PPI.Load(id)
if not iface then
if callbacks.failure then
callbacks.failure(is_reloaded)
end
elseif is_reloaded then
if callbacks.success then
callbacks.success(iface)
end
end
end
end


-- PPI invocation resolver
_G[invoke_msg] = function(id)
Expand Down Expand Up @@ -387,4 +411,4 @@ end


-- Return the module table
return PPI
return PPI
104 changes: 52 additions & 52 deletions MapWindow.plugin/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
<!DOCTYPE muclient>
<muclient>
<plugin
name="MapWindow"
author="Soludra"
id="37859615f6c4f74b6872f8e6"
language="Lua"
purpose="Moves the MAP into a floating miniwindow"
save_state="y"
date_written="2009-04-11 21:52:18"
requires="4.40"
version="1.0"
>
<description trim="y">
<![CDATA[
MapWindow v1.0
By Soludra Ar'thela
This plugin is best used alongside my ATCP plugin. Its messages allow
the MapWindow to update every time you move, even by summons or other
"nonstandard" means.
Commands:
MAP RADIUS <1-5>
-> Sets the MAP radius, which affects the mapwindow size.
-> MAP WIDTH and MAP HEIGHT also work as expected.
MAP MOVE
-> Displays the current map-window location
MAP MOVE <x> <y>
-> Positions the map window in a specific location on the screen.
-> 0 0 is the top-left corner.
MAP FONTSIZE <font size>
-> Sets the size each symbol takes up.
-> Default is 10. Is not yet saved between sessions.
MAP PARSE
-> Updates the map with MAP, gagging the output.
-> You shouldn't need to use this yourself unless you
-> don't have the ATCP plugin installed.
]]>
</description>
</plugin>
<include name="constants.lua"/>
<include name="$PLUGINDIR\libraries\plugger.xml" />
<!DOCTYPE muclient>

<muclient>
<plugin
name="MapWindow"
author="Soludra"
id="209dea6f781761999cf9cb14"
language="Lua"
purpose="Moves the MAP into a floating miniwindow"
save_state="y"
date_written="2009-04-11 21:52:18"
requires="4.65"
version="3.0"
>

<description trim="y"><![CDATA[
MapWindow v3.0
By Rollanz, based on Soludra's MapWindow v2.001
By Soludra Ar'thela

This plugin is best used alongside my ATCP plugin. Its messages allow
the MapWindow to update every time you move, even by summons or other
"nonstandard" means.

Commands:
MAP RADIUS <1-5>
-> Sets the MAP radius, which affects the mapwindow size.
-> MAP WIDTH and MAP HEIGHT also work as expected.

MAP MOVE
-> Displays the current map-window location

MAP MOVE <x> <y>
-> Positions the map window in a specific location on the screen.
-> 0 0 is the top-left corner.

MAP FONTSIZE <font size>
-> Sets the size each symbol takes up.
-> Default is 10. Is not yet saved between sessions.

MAP PARSE
-> Updates the map with MAP, gagging the output.
-> You shouldn't need to use this yourself unless you
-> don't have the ATCP plugin installed.
]]></description>

</plugin>


<include name="constants.lua"/>
<include name="$PLUGINDIR\libraries\plugger.xml" />

</muclient>
7 changes: 7 additions & 0 deletions MapWindow.plugin/project.kpf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Komodo Project File - DO NOT EDIT -->
<project id="c2e114d9-4094-46bd-a991-434c18af2341" kpf_version="4" name="MapWindow">
<preference-set idref="c2e114d9-4094-46bd-a991-434c18af2341">
<boolean id="import_live">1</boolean>
</preference-set>
</project>
57 changes: 57 additions & 0 deletions MapWindow.plugin/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
MapWindow.plugin, version 2.0.1
By Soludra Ar'thela

+--------------+
| Requirements |
+--------------+

* MUSHclient v4.56 or higher
* GMCP plugin, by Soludra

+--------------+
| Installation |
+--------------+

1. In MUSHclient, File -> Plugins.
2. Click Add.
3. Browse to the same directory as this readme.txt
4. Select 'plugin.xml' and click Open.

If using alongside compass.plugin and gauges.plugin in their original positions:
5. Use the alias "MAP MOVE 0 152". This should position the map just below the
gauges.
6. Use MAP WIDTH 4 to make the map fit between the edge of the screen and the text.

+-------+
| Usage |
+-------+

This plugin takes the MAP output and creates a floating miniwindow with it. It
automatically updates itself as you move.

Use MAP HELP to view the list of commands that can be used.

+----------------------------+
| Frequently Asked Questions |
+----------------------------+

1. The map doesn't appear/update!
A. The plugin may not be enabled. Go to File -> Plugins and make sure it's
enabled.

You may also be in an area where there is no map; you should use MAP yourself
to check.

In some cases - after death, or after passing through unmapped terrain, for
instance - the map may not update. You should use MAP once or twice manually.
This is a known issue.

Please also see the Troubleshooting section for the GMCP plugin.

2. Nothing's appearing on the screen, but I see my health falling! (or other
gagged-output issues)
A. In semi-rare cases, the MapWindow will gag everything in its path. This is a
known issue. You should use MAP once or twice to kick it back into gear.

In general, if something strange happens regarding the map, using MAP once
or twice manually should, in most cases, get it working again.
Loading