Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Message
| I got a couple of triggers to work nicely, it was a bit trickier than I thought, as I haven't looked at it for a while, and things have changed a bit.
<triggers>
<trigger
enabled="y"
match="<*/* hp */* m */* mv */* xp>*"
name="status_prompt"
send_to="12"
sequence="100"
>
<send>
-- calculate percentages, put them in a table
status_table = {
%1/%2 * 100, -- hp
%3/%4 * 100, -- mana
%5/%6 * 100, -- movement
%7/%8 * 100, -- xp
}
if not status_window_open then
status_window_open = true
udp = function (msg)
UdpSend ("127.0.0.1", 4111, "magic," .. msg)
end
os.execute ('start "statusbar" "' .. GetInfo (66) .. 'StatusBar.exe"')
-- it might take a second to start up StatusBar.exe, so do this a second later
DoAfterSpecial (1, [[
udp ("title,Status Bar - SMAUG")
udp ("config,10,5,100,15,60,320,20")
udp ("size,10,10,350,140")
udp ("textcolour," .. ColourNameToRGB ("indigo"))
udp ("backcolour," .. ColourNameToRGB ("lightsteelblue"))
udp ("labels,HP,Mana,Move,XP")
udp ("font,Comic Sans MS,10,0,700")
udp ("colours," ..
ColourNameToRGB ("darkgreen") .. "," ..
ColourNameToRGB ("darkblue") .. "," ..
ColourNameToRGB ("saddlebrown") .. "," ..
ColourNameToRGB ("dimgray"))
udp ("fillcolours," ..
ColourNameToRGB ("lightgreen") .. "," ..
ColourNameToRGB ("lightblue") .. "," ..
ColourNameToRGB ("tan") .. "," ..
ColourNameToRGB ("gainsboro"))
udp ("values," .. table.concat (status_table or {}, ","))
ActivateClient () -- get focus back
]], 12)
else
udp ("values," .. table.concat (status_table, ","))
end -- first time
</send>
</trigger>
<trigger
enabled="y"
keep_evaluating="y"
match="Exits: *"
send_to="12"
sequence="100"
>
<send>
if udp then
udp ("text,5,88,%0")
end -- status window available
</send>
</trigger>
</triggers>
To make this work, first I set my SMAUG prompt to show all the stuff it needs:
prompt <%h/%H hp %m/%M m %v/%V mv %x/%X xp>
That is, current and max HP, current and max Mana, current and max movement points, xp and XP to go. This lets me calculate percentages for the status bar.
Then after installing the statusbar.exe from:
http://www.gammon.com.au/files/utils/statusbar.zip
It was ready to work. What the first trigger does is calculate the percentages, and then the first time around, it uses os.execute to start up the statusbar.exe program. (You need to make the world "trusted" for this to work). It then uses DoAfterSpecial to configure the status window a second later. The reason for this is to give the status bar program time to start.
From then on, each prompt updates the status bar.
The second trigger updates the current exits. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|