-
Notifications
You must be signed in to change notification settings - Fork 15
/
Room_Location_Telnet.xml
169 lines (128 loc) · 4.66 KB
/
Room_Location_Telnet.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="Room_Location_Telnet"
author="Nick Gammon"
id="00ceb6f44bc36ed815a93950"
language="Lua"
purpose="Shows where we are in a miniwindow"
date_written="2010-02-02"
requires="4.40"
version="1.0"
save_state="y"
>
<description trim="y">
<![CDATA[
Install this plugin to show an your current room name and exits.
The window can be dragged to a new location with the mouse.
]]>
</description>
</plugin>
<!-- Script -->
<script>
<![CDATA[
FONT_NAME = "Fixedsys" -- the font we want to use
FONT_SIZE = 9
FONT_ID = "fn" -- internal font identifier
require "movewindow"
function OnPluginInstall ()
win = GetPluginID ()
WindowCreate (win, 0, 0, 0, 0, 0, 0, 0)
-- add the font
WindowFont (win, FONT_ID, FONT_NAME, FONT_SIZE)
-- see how high it is
font_height = WindowFontInfo (win, FONT_ID, 1) -- height
-- find where window was last time
windowinfo = movewindow.install (win, 7)
end -- OnPluginInstall
function OnPluginEnable ()
WindowShow (win, true)
end -- OnPluginDisable
function OnPluginDisable ()
WindowShow (win, false)
end -- OnPluginDisable
-- hide window on removal
function OnPluginClose ()
WindowShow (win, false) -- hide it
end -- OnPluginClose
function OnPluginSaveState ()
movewindow.save_state (win)
end -- OnPluginSaveState
-- here when location changes
--[[
example line (extra lines added for clarity):
tt="move";room=21056;name="Quills and Parchments";
blind=false;dark=false;
exits={north=21047;west=21053;};
--]]
function OnPluginTelnetOption (option)
local t = {} -- incoming server variables will go into table t
setfenv (assert (loadstring (option)), t) () -- compile and load into t
if not t.move then
return
end
local width = 0
local lines = 1 -- have at least one line
local dark_message = "It is too dark to see."
local blind_message = "You are blind!"
local exits_message = "Exits:"
local background_colour = ColourNameToRGB "darkkhaki"
if t.move.dark then
width = WindowTextWidth (win, FONT_ID, dark_message, true)
elseif t.move.blind then
width = WindowTextWidth (win, FONT_ID, blind_message, true)
else
width = WindowTextWidth (win, FONT_ID, t.move.name, true)
if t.move.exits and next (t.move.exits) then
width = math.max (width, WindowTextWidth (win, FONT_ID, exits_message, true))
lines = lines + 2
for k, v in pairs (t.move.exits) do
width = math.max (width, 10 + WindowTextWidth (win, FONT_ID, k, true))
lines = lines + 1
end -- for each exit
end -- if
end -- if
window_width = width + 10
window_height = font_height * lines + 10
WindowCreate (win,
windowinfo.window_left,
windowinfo.window_top,
window_width, window_height,
windowinfo.window_mode, -- top right
windowinfo.window_flags,
0)
-- let them t.move it around
movewindow.add_drag_handler (win, 0, 0, 0, 0)
-- fill entire box to clear it
WindowRectOp (win, 2, 0, 0, 0, 0, background_colour) -- fill entire box
-- Edge around box rectangle
WindowCircleOp (win, 3, 0, 0, 0, 0, ColourNameToRGB "darkgray", 0, 2, 0, 1)
if t.move.blind then
WindowText (win, FONT_ID, blind_message, 5, 5, 0, 0, ColourNameToRGB "darkred", true)
elseif t.move.dark then
WindowText (win, FONT_ID, dark_message, 5, 5, 0, 0, ColourNameToRGB "darkgreen", true)
else
vertical = 5 -- pixel to start at
WindowText (win, FONT_ID, t.move.name, 5, 5, 0, 0, ColourNameToRGB "saddlebrown", true)
vertical = vertical + font_height * 2 -- leave blank line
if t.move.exits and next (t.move.exits) then
WindowText (win, FONT_ID, exits_message, 5, vertical, 0, 0, ColourNameToRGB "black", true)
for k, v in pairs (t.move.exits) do
vertical = vertical + font_height
WindowText (win, FONT_ID, k, 15, vertical, 0, 0, ColourNameToRGB "darkolivegreen", true)
end -- for each exit
end -- if
end -- if
-- 3D box
WindowCircleOp (win, 3, 0, 0, 0, 0, 0x505050, 0, 3, 0, 1) -- dark grey border (3 pixels)
WindowCircleOp (win, 3, 1, 1, -1, -1, 0x7C7C7C, 0, 1, 0, 1) -- lighter inner border
WindowCircleOp (win, 3, 2, 2, -2, -2, 0, 0, 1, 0, 1) -- black inside that
WindowLine (win, 1, 1, window_width - 1, 1, 0xC2C2C2, 0, 1) -- light top edge
WindowLine (win, 1, 1, 1, window_height - 1, 0xC2C2C2, 0, 1) -- light left edge (for 3D look)
-- make sure window visible
WindowShow (win, true)
end -- function OnPluginTelnetOption
]]>
</script>
</muclient>