Skip to content

Commit af19780

Browse files
+win_group.xml
1 parent b02b799 commit af19780

File tree

1 file changed

+346
-0
lines changed

1 file changed

+346
-0
lines changed

Packages/win_group.xml

Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE MudletPackage>
3+
<MudletPackage version="1.001">
4+
<TriggerPackage>
5+
<Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
6+
<name>OnConnect</name>
7+
<script>win_group.enableGroupMsdp()
8+
</script>
9+
<triggerType>0</triggerType>
10+
<conditonLineDelta>0</conditonLineDelta>
11+
<mStayOpen>0</mStayOpen>
12+
<mCommand></mCommand>
13+
<packageName></packageName>
14+
<mFgColor>#ff0000</mFgColor>
15+
<mBgColor>#ffff00</mBgColor>
16+
<mSoundFile></mSoundFile>
17+
<colorTriggerFgColor>#000000</colorTriggerFgColor>
18+
<colorTriggerBgColor>#000000</colorTriggerBgColor>
19+
<regexCodeList>
20+
<string>Welcome to the land of SlothMUD. May your visit here be... Interesting.</string>
21+
<string>Reconnecting.</string>
22+
</regexCodeList>
23+
<regexCodePropertyList>
24+
<integer>3</integer>
25+
<integer>3</integer>
26+
</regexCodePropertyList>
27+
</Trigger>
28+
</TriggerPackage>
29+
<TimerPackage>
30+
<Timer isActive="no" isFolder="no" isTempTimer="no" isOffsetTimer="no">
31+
<name>test msdp.GROUP data</name>
32+
<script>-- test data
33+
34+
msdp = msdp or {}
35+
msdp.GROUP = {
36+
MEMBER0 = {
37+
MANA = "595",
38+
POSITION = "Back",
39+
MAX_MOVES = "217",
40+
MAX_HITPOINTS = "803",
41+
MOVES = "193",
42+
CLASS = "Ne",
43+
LEVELS = "4.27",
44+
MAX_MANA = "595",
45+
STATUS = "Standing",
46+
HITPOINTS = "803",
47+
NAME = "Dorp"
48+
},
49+
MEMBER3 = {
50+
MANA = "544",
51+
POSITION = "Front",
52+
MAX_MOVES = "375",
53+
MAX_HITPOINTS = "1148",
54+
MOVES = "363",
55+
CLASS = "Ne",
56+
LEVELS = "9.40",
57+
MAX_MANA = "1054",
58+
STATUS = "Fighting",
59+
HITPOINTS = "1148",
60+
NAME = "Beatrix"
61+
},
62+
MEMBER6 = {
63+
MANA = "401",
64+
POSITION = "Point",
65+
MAX_MOVES = "404",
66+
MAX_HITPOINTS = "1464",
67+
MOVES = "357",
68+
CLASS = "Wa",
69+
LEVELS = "8.36",
70+
MAX_MANA = "503",
71+
STATUS = "Fighting",
72+
HITPOINTS = math.random(-50,1500),
73+
NAME = "Roselya"
74+
},
75+
MEMBER4 = {
76+
MANA = "576",
77+
POSITION = "Back",
78+
MAX_MOVES = "378",
79+
MAX_HITPOINTS = "1147",
80+
MOVES = "352",
81+
CLASS = "Dr",
82+
LEVELS = "8.39",
83+
MAX_MANA = "876",
84+
STATUS = "Fighting",
85+
HITPOINTS = "1147",
86+
NAME = "Fandral"
87+
},
88+
MEMBER7 = {
89+
MANA = "649",
90+
POSITION = "Front",
91+
MAX_MOVES = "551",
92+
MAX_HITPOINTS = "1836",
93+
MOVES = "543",
94+
CLASS = "Wa",
95+
LEVELS = "9.40",
96+
MAX_MANA = "820",
97+
STATUS = "Standing",
98+
HITPOINTS = "1836",
99+
NAME = "Stun"
100+
},
101+
MEMBER1 = {
102+
MANA = "584",
103+
POSITION = "Back",
104+
MAX_MOVES = "234",
105+
MAX_HITPOINTS = "774",
106+
MOVES = "234",
107+
CLASS = "Ne",
108+
LEVELS = "0.39",
109+
MAX_MANA = "584",
110+
STATUS = "Fighting",
111+
HITPOINTS = "774",
112+
NAME = "Ninx"
113+
},
114+
MEMBER9 = {
115+
MANA = "538",
116+
POSITION = "Leader",
117+
MAX_MOVES = "218",
118+
MAX_HITPOINTS = "812",
119+
MOVES = "192",
120+
CLASS = "Cl",
121+
LEVELS = "0.39",
122+
MAX_MANA = "736",
123+
STATUS = "Fighting",
124+
HITPOINTS = "812",
125+
NAME = "Toxis"
126+
},
127+
MEMBER8 = {
128+
MANA = "474",
129+
POSITION = "Back",
130+
MAX_MOVES = "259",
131+
MAX_HITPOINTS = "759",
132+
MOVES = "238",
133+
CLASS = "Ma",
134+
LEVELS = "4.32",
135+
MAX_MANA = "617",
136+
STATUS = "Fighting",
137+
HITPOINTS = "759",
138+
NAME = "Fuligin"
139+
},
140+
MEMBER5 = {
141+
MANA = "731",
142+
POSITION = "Front",
143+
MAX_MOVES = "530",
144+
MAX_HITPOINTS = "1547",
145+
MOVES = "530",
146+
CLASS = "Mo",
147+
LEVELS = "9.40",
148+
MAX_MANA = "731",
149+
STATUS = "Fighting",
150+
HITPOINTS = "1547",
151+
NAME = "Belrath"
152+
},
153+
MEMBER2 = {
154+
MANA = "571",
155+
POSITION = "Front",
156+
MAX_MOVES = "414",
157+
MAX_HITPOINTS = "1307",
158+
MOVES = "398",
159+
CLASS = "Wa",
160+
LEVELS = "8.33",
161+
MAX_MANA = "571",
162+
STATUS = "Dead",
163+
HITPOINTS = "-1307",
164+
NAME = "Braze"
165+
},
166+
}
167+
raiseEvent("msdp.GROUP")</script>
168+
<command></command>
169+
<packageName></packageName>
170+
<time>00:00:05.000</time>
171+
</Timer>
172+
</TimerPackage>
173+
<AliasPackage />
174+
<ActionPackage />
175+
<ScriptPackage>
176+
<Script isActive="yes" isFolder="no">
177+
<name>win_group</name>
178+
<packageName></packageName>
179+
<script>-- This script creates an Adjustable Container window named "win_group"
180+
-- see: https://www.mudlet.org/geyser/files/geyser/AdjustableContainer.html
181+
182+
-- If you closed the window and want it to come back
183+
-- win_group:show()
184+
-- or lua win_group:show() from console input line
185+
186+
-- If you locked the container and want to be able to move/drag/resize it again
187+
-- win_group:unlockContainer()
188+
-- or lua win_group:unlockContainer() from console input
189+
190+
-- If you want to lock the container in place so you don't move/drag/resize it on accident
191+
-- win_group:lockContainer()
192+
-- or lua win_group:lockContainer() from console_input
193+
194+
win_group = win_group or Adjustable.Container:new({
195+
name = "win_group",
196+
y = "0%",
197+
height = "10%",
198+
autoload = false,
199+
adjLabelstyle = "border:1px solid #458588;border-radius: 4px;background-color:black;",
200+
titleText = "Group"
201+
})
202+
203+
-- Put a console inside the window to write text to
204+
win_group_con_all = Geyser.MiniConsole:new({
205+
name = "win_group_con_all",
206+
x = 0,
207+
y = 0,
208+
autoWrap = false,
209+
scrollBar = false,
210+
width = "100%",
211+
height = "100%",
212+
}, win_group)
213+
214+
215+
win_group_con_all:setColor("black") -- set console background color
216+
setMiniConsoleFontSize("win_group_con_all",9) -- set console font size </script>
217+
<eventHandlerList />
218+
</Script>
219+
<Script isActive="yes" isFolder="no">
220+
<name>enableGroupMsdp</name>
221+
<packageName></packageName>
222+
<script>win_group = win_group or {}
223+
224+
-- register with Sloth that we want it to send us msdp.GROUP and CHARACTER_NAME
225+
function win_group.enableGroupMsdp()
226+
if not msdp then
227+
cecho("\n")
228+
cecho("&lt;firebrick&gt;[&lt;red&gt;WARN&lt;firebrick&gt;]&lt;reset&gt; MSDP does not appear to be enabled on this Mudlet profile.\n")
229+
cecho(" To enable: From Mudlet menu --&gt; Options --&gt; Preferences: Enable MSDP (check box)\n")
230+
cecho(" You may need to reconnect Mudlet after enabling.\n")
231+
end
232+
sendMSDP("REPORT","GROUP")
233+
sendMSDP("REPORT","CHARACTER_NAME")
234+
end</script>
235+
<eventHandlerList />
236+
</Script>
237+
<Script isActive="yes" isFolder="no">
238+
<name>msdpGroupWinHandler</name>
239+
<packageName></packageName>
240+
<script>-- each time Sloth sends an msdp.GROUP update, this function will be called to update the window
241+
function msdpGroupWinHandler()
242+
243+
-- msdp returns the group members in no order I understand so we'll assign points based on group position to help in sorting
244+
sortOrder = {
245+
[ [[Point]] ] = 60,
246+
[ [[Pleader]] ] = 60,
247+
[ [[Leader]] ] = 40,
248+
[ [[Front]] ] = 20,
249+
[ [[Back]] ] = 0,
250+
}
251+
252+
-- first clear the console since we're about to write the newest status of the group
253+
win_group_con_all:clear()
254+
255+
lastPos = nil -- used to insert blank lines between point, leader, front back (ie, on position changes)
256+
257+
-- iterate through each group member
258+
-- (using spairs to sort based on our made up sortOrder points + char levels)
259+
for _,v in spairs(msdp.GROUP,function(t,a,b) return (sortOrder[t[b].POSITION] or 0)+tonumber(t[b].LEVELS) &lt; (sortOrder[t[a].POSITION] or 0)+tonumber(t[a].LEVELS) end) do
260+
261+
-- the following is not how i would normally do this but to make it self contained and easy to read
262+
263+
-- char name
264+
local name = string.format("%-12s",v.NAME, 12)
265+
-- highlight our own name
266+
if v.NAME == msdp.CHARACTER_NAME then
267+
name = "&lt;:dark_slate_grey&gt;"..name
268+
end
269+
270+
-- hp string
271+
local hp = string.format("%5s",v.HITPOINTS,5)
272+
local hpR = tonumber(v.HITPOINTS) / tonumber(v.MAX_HITPOINTS)
273+
local hpColor
274+
if hpR &lt; .2 then hpColor = "&lt;red&gt;"
275+
elseif hpR &lt; .8 then hpColor = "&lt;orange&gt;"
276+
else hpColor = "&lt;green&gt;"
277+
end
278+
279+
-- ma string
280+
local ma = string.format("%5s",v.MANA,5)
281+
local maR = tonumber(v.MANA) / tonumber(v.MAX_MANA)
282+
local maColor
283+
if maR &lt; .2 then maColor = "&lt;red&gt;"
284+
elseif maR &lt; .8 then maColor = "&lt;orange&gt;"
285+
else maColor = "&lt;green&gt;"
286+
end
287+
288+
-- mv string
289+
local mv = string.format("%4s",v.MOVES,4)
290+
local mvR = tonumber(v.MOVES) / tonumber(v.MAX_MOVES)
291+
local mvColor
292+
if mvR &lt; .2 then mvColor = "&lt;red&gt;"
293+
elseif mvR &lt; .8 then mvColor = "&lt;orange&gt;"
294+
else mvColor = "&lt;green&gt;"
295+
end
296+
297+
-- position string
298+
local pos = string.format("%8s",v.POSITION,8)
299+
local seperator = ""
300+
if lastPos ~= pos then
301+
lastPos = pos
302+
seperator = "\n"
303+
end
304+
305+
-- status, symbol and name color
306+
local symbol = " "
307+
local nameColor = ""
308+
local status = string.format("%10s",v.STATUS,10)
309+
local statusColor
310+
if (v.STATUS == "Standing") then
311+
statusColor = "&lt;green&gt;"
312+
elseif (v.STATUS == "Fighting") then
313+
statusColor = "&lt;orange&gt;"
314+
elseif (v.STATUS == "Dead") then
315+
statusColor = "&lt;red&gt;"
316+
nameColor = "&lt;red&gt;"
317+
symbol = "💀"
318+
else
319+
statusColor = "&lt;red&gt;" -- if leading I want to see all green if moving
320+
end
321+
322+
-- put it all together to write the line
323+
win_group_con_all:cecho(
324+
seperator..
325+
symbol..
326+
nameColor..
327+
name.."&lt;reset&gt;"..
328+
hpColor..hp.."&lt;reset&gt;hp "..
329+
maColor..ma.."&lt;reset&gt;ma "..
330+
mvColor..mv.."&lt;reset&gt;mv "..
331+
pos..
332+
statusColor..status..
333+
"\n"
334+
)
335+
end
336+
end</script>
337+
<eventHandlerList>
338+
<string>msdp.GROUP</string>
339+
</eventHandlerList>
340+
</Script>
341+
</ScriptPackage>
342+
<KeyPackage />
343+
<HelpPackage>
344+
<helpURL></helpURL>
345+
</HelpPackage>
346+
</MudletPackage>

0 commit comments

Comments
 (0)