Repository navigation
Expand file tree
/
Copy pathstatus.py
More file actions
38 lines (32 loc) · 1.43 KB
/
Copy pathstatus.py
File metadata and controls
38 lines (32 loc) · 1.43 KB
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
"""Your character's state in one line, as the parser sees it: ;status
;status room | posture and badges | vitals | hands | hostiles | with | creatures | RT
;status watch print it again whenever it changes, until stopped
;status return (typed while watching) end the watch
The same view scripts use: `from client.game.status import status`,
then `status(s.state).stunned`, `.posture`, `.hands_empty`,
`.roundtime`, `.mindstate("Attunement")` — Lich's stunned?/hidden?/
checkprone idiom over the parser's raw indicator, vitals, hands,
room, hostiles, the room's players and creatures (`.players`,
`.creatures`, #178) and clock fields (client/game/status.py). It reads
the parser's state only and sends nothing; a state the game has not
pushed yet reads as None or 0, so the line right after login can be
thinner than a minute later. Stop with: ;stop status
"""
from client.game.status import status
POLL = 0.5 # seconds between looks while watching
def main(s):
words = [str(a).lower() for a in (s.args or [])]
view = status(s.state)
s.echo(f"status: {view.summary()}")
if "watch" not in words:
return
last = view.summary()
while True:
line = s.command(timeout=POLL)
if line and "return" in line.lower():
s.echo("status: watch ended")
return
now = view.summary()
if now != last:
s.echo(f"status: {now}")
last = now