Alright so after following Nick's completely awesome inventory mini window (your the man :P), I've finally managed to come up with a script that actually captures the map from my output, and redirects it into a mini window. Now of course, there is always one more problem. Before I go any further, here is my script.
require "wait"
function MapView_Redirect ()
wait.make (function () -- coroutine starts here
local win = GetPluginID () .. ":map"
local font = "f"
if not WindowInfo (win, 1) then
WindowCreate (win, 0, 0, 0, 0, 6, 0, 0)
WindowFont (win, font, "Lucida Console", 9)
end -- if
-- request map
Send "look"
-- wait for map to start
local x = wait.match ("-*- v* -*-")
if not x then
ColourNote ("white", "blue", "No map received within 5 seconds")
return
end -- if
local map = {}
local max_width = WindowTextWidth (win, font, "Map")
-- loop untill end of map
while true do
local line, wildcards, styles = wait.match ("*")
-- save map
table.insert (map, styles)
-- work out max width
max_width = math.max (max_width, WindowTextWidth (win, font, line))
-- see if end of map
if string.match (line, "^-*- %d+:%d+:%d+ -*-") or
string.match (line, "^-* %-%d+:%d+:%d+ -*-") or
string.match (line, "^-* %d+:%-%d+:%d+ -*-") or
string.match (line, "^-* %d+:%d+:%-%d+ -*-") or
string.match (line, "^-* %-%d+:%-%d+:%d+ -*-") or
string.match (line, "^-* %d+:%-%d+:%-%d+ -*-") or
string.match (line, "^-* %-%d+:%d+:%-%d+ -*-") or
string.match (line, "^-* %-%d+:%-%d+:%-%d+ -*-") then
break
end -- if
end -- while
local font_height = WindowFontInfo (win, font, 1)
local window_width = max_width + 10
local window_height = font_height * (#map + 2) +10
-- make window correct size
WindowCreate (win, 0, 0, window_width, window_height, 6, 0, ColourNameToRGB "#373737")
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
-- heading line
WindowText (win, font, "Map:", 5, 5, 0, 0, ColourNameToRGB "yellow")
-- draw each map line
local y = font_height * 2 + 5
for i, styles in ipairs (map) do
local x = 5
for _, style in ipairs (styles) do
x = x + WindowText (win, font, style.text, x, y, 0, 0, style.textcolour)
end -- for
y = y + font_height
end -- for each inventory item
WindowShow (win, true)
end) -- end of coroutine
end -- function MapView_Redirect()
Now this works all fine and dandy, but there is one problem. I use these three triggers to omit the map from the output and...
<triggers>
<trigger
enabled="y"
expand_variables="y"
keep_evaluating="y"
match="^\-\-\-\-\-\-\-\-\-\-\- v4512 \-\-\-\-\-\-\-\-\-\-\-$"
name="start"
omit_from_log="y"
omit_from_output="y"
regexp="y"
send_to="14"
sequence="100"
>
<send>EnableTrigger("middle", true)
EnableTrigger("end", true)
</send>
</trigger>
</triggers>
<triggers>
<trigger
expand_variables="y"
keep_evaluating="y"
match="^(.*?)$"
name="middle"
omit_from_log="y"
omit_from_output="y"
regexp="y"
send_to="14"
sequence="100"
>
</trigger>
</triggers>
<triggers>
<trigger
expand_variables="y"
lines_to_match="10"
keep_evaluating="y"
match="^\-\-\-\-\-\-\-\-\-\- 2\:18\:0 \-\-\-\-\-\-\-\-\-\-\-$"
name="end"
omit_from_log="y"
omit_from_output="y"
regexp="y"
send_to="14"
sequence="100"
>
<send>EnableTrigger("end", false)
EnableTrigger("middle", false)
</send>
</trigger>
</triggers>
it does omit the map from the output like I wanted it to, but, when I manually call the script that redirects the map, it doesn't omit the map from the output anymore, and sometimes will omit half the map, its weird. Bottom line is when I call the map redirect while I'm in a room where the map SHOULD be omitted, the map doesn't get omitted all the way, even though it should be. The map redirect seems to still work though. Another thing, in some rooms, when I walk in and call the script, the mini window seems to "blow up" across the whole screen. I've been stumped on these problems for the past few days and help would be greatly appreciated. Thanks again. |