Thanks for the reply!
Ya that is the tutorial I watched earlier (read previous post about tutorial #2)
I am not very fluent in Lua so I tried a few things with it but could never get it to quite work. The best I had it doing was to list all of the damage section. (that's the part below "Fatigue: Fully Rested Hunger: Well-Fed" and above "(To view your skills, type skills"
I even let it go at that at one point but the problem is it would no longer let me use other triggers to omit the lines of the original output. The reason I am omitting that is because I want to set up triggers to have the status update frequently and don't want to have it cluttering up the screen with the same info over and over again to do so. (kinda a secret update or a move to status window dealio)
I'll show what I tried:
require "wait"
wait.make (function () -- coroutine starts here
local win = GetPluginID () .. ":status"
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 inventory
Send "i" -- this mud uses the letter i to get the status
-- wait for status screen to start
local x = wait.match ("Name: *", 10)
if not x then
ColourNote ("white", "blue", "No status received within 10 seconds")
return
end -- if
local inv = {}
local max_width = WindowTextWidth (win, font, "Status")
-- loop until end of status
while true do
local line, wildcards, styles = wait.match ("*")
-- see if end of status
if string.match ("(To view *") then
break
end -- if
-- save status line
table.insert (inv, styles)
-- work out max width
max_width = math.max (max_width, WindowTextWidth (win, font, line))
end -- while loop
local font_height = WindowFontInfo (win, font, 1)
local window_width = max_width + 10
local window_height = font_height * (#inv + 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, "Status", 5, 5, 0, 0, ColourNameToRGB "blue")
-- draw each status line
local y = font_height * 2 + 5
for i, styles in ipairs (inv) 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 status item
WindowShow (win, true)
end) -- end of coroutine
It would seem the problem area is the match loop. So without altering it too much I made another version as close to the original as I could
(matching loop portion only)
local x = wait.match ("Fatigue: *", 10)
if not x then
ColourNote ("white", "blue", "No inventory received within 10 seconds")
return
end -- if
local inv = {}
local max_width = WindowTextWidth (win, font, "Inventory")
-- loop until end of inventory
while true do
local line, wildcards, styles = wait.match ("*")
-- see if end of inventory
if not string.match ("Your *") then
break
end -- if
The one above at least did something but I was missing a lot of info from the status screen and I was unable to omit the parts from the output that I -WAS- able push up to the window.
I even tried to get fancy and use regular expressions (which don't seem to work in this format)
local x = wait.match ("^Name\: (.*?) Race\: (.*?) Gender\: (.*?)$", 10)
if not x then
ColourNote ("white", "blue", "No inventory received within 10 seconds")
return
end -- if
local inv = {}
local max_width = WindowTextWidth (win, font, "Inventory")
-- loop until end of inventory
while true do
local line, wildcards, styles = wait.match ("*")
-- see if end of inventory
if string.match ("^\(To view your skills\, type skills$") then
break
end -- if
Odds are I am overlooking something simple. (like I said I'm new) But if there is a way to match the entire status screen and omit it from output. Please let me know. |