Add online player positions to sudo context

This commit is contained in:
Claude Code
2026-03-16 19:41:52 -04:00
parent b6c8abdeea
commit cc9c1b3ae4
+23 -1
View File
@@ -1412,10 +1412,32 @@ def process_sudo(player, prompt, config):
)
online = players_online(config)
# Collect positions for all currently online players only.
position_lines = []
for p in online:
try:
pos_raw = rcon(
f"data get entity {p} Pos",
config["rcon_host"], config["rcon_port"], config["rcon_password"]
)
pos_m = re.findall(r'(-?[\d.]+)d', pos_raw)
if pos_m and len(pos_m) >= 3:
x, y, z = int(float(pos_m[0])), int(float(pos_m[1])), int(float(pos_m[2]))
position_lines.append(f" {p}: x={x}, y={y}, z={z}")
except Exception:
pass
positions_block = (
"Player positions:\n" + "\n".join(position_lines)
if position_lines else ""
)
context_hint = (
f"Requesting player: {player}\n"
f"Online players: {', '.join(online) or 'none'}\n"
f"Natural language request: {prompt}\n"
+ (positions_block + "\n" if positions_block else "")
+ f"Natural language request: {prompt}\n"
+ get_sudo_history_block()
)