Add online player positions to sudo context
This commit is contained in:
+22
-1
@@ -2367,10 +2367,31 @@ def process_sudo(player, prompt, config):
|
|||||||
add_sudo_history(player, prompt, commands, executed)
|
add_sudo_history(player, prompt, commands, executed)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Collect positions for all online players.
|
||||||
|
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 = (
|
context_hint = (
|
||||||
f"Requesting player: {player}\n"
|
f"Requesting player: {player}\n"
|
||||||
f"Online players: {', '.join(online) or 'none'}\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()
|
+ get_sudo_history_block()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user