Skip to content

Commit d01cc1e

Browse files
feat(lua): add AI context action-menu macros
Assisted-by: openai/gpt-5.3-codex on opencode Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
1 parent cd8c351 commit d01cc1e

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

data/lua/lib/action_menu_macros.lua

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,65 @@ local function announce_current_turn()
3838
gapi.add_msg(string.format(locale.gettext("Current turn: %d"), turn_value))
3939
end
4040

41+
local function report_agent_context()
42+
local avatar = gapi.get_avatar()
43+
local map = gapi.get_map()
44+
local pos = avatar:get_pos_ms()
45+
local turn_value = gapi.current_turn():to_turn()
46+
local details = string.format(
47+
"[AI] turn=%d local_ms=(%d,%d,%d) outside=%s sheltered=%s",
48+
turn_value,
49+
pos.x,
50+
pos.y,
51+
pos.z,
52+
tostring(map:is_outside(pos)),
53+
tostring(map:is_sheltered(pos))
54+
)
55+
gapi.add_msg(details)
56+
end
57+
58+
local function report_look_target()
59+
local target = gapi.look_around()
60+
if not target then
61+
gapi.add_msg(locale.gettext("Look canceled."))
62+
return
63+
end
64+
65+
local target_abs = gapi.get_map():get_abs_ms(target)
66+
gapi.add_msg(
67+
string.format(
68+
"[AI] look local_ms=(%d,%d,%d) abs_ms=(%d,%d,%d)",
69+
target.x,
70+
target.y,
71+
target.z,
72+
target_abs.x,
73+
target_abs.y,
74+
target_abs.z
75+
)
76+
)
77+
end
78+
79+
local function report_adjacent_choice()
80+
local target = gapi.choose_adjacent(locale.gettext("Choose adjacent tile for AI context"), true)
81+
if not target then
82+
gapi.add_msg(locale.gettext("Adjacent selection canceled."))
83+
return
84+
end
85+
86+
local target_abs = gapi.get_map():get_abs_ms(target)
87+
gapi.add_msg(
88+
string.format(
89+
"[AI] adjacent local_ms=(%d,%d,%d) abs_ms=(%d,%d,%d)",
90+
target.x,
91+
target.y,
92+
target.z,
93+
target_abs.x,
94+
target_abs.y,
95+
target_abs.z
96+
)
97+
)
98+
end
99+
41100
action_menu_macros.register_defaults = function()
42101
gapi.register_action_menu_entry({
43102
id = "bn_macro_recent_messages",
@@ -62,6 +121,30 @@ action_menu_macros.register_defaults = function()
62121
category = "info",
63122
fn = announce_current_turn,
64123
})
124+
125+
gapi.register_action_menu_entry({
126+
id = "bn_macro_agent_context",
127+
name = locale.gettext("AI Context Packet"),
128+
description = locale.gettext("Print turn, local coordinates, and shelter/outside state."),
129+
category = "info",
130+
fn = report_agent_context,
131+
})
132+
133+
gapi.register_action_menu_entry({
134+
id = "bn_macro_look_target",
135+
name = locale.gettext("AI Look Target"),
136+
description = locale.gettext("Pick a tile via look-around and print local/absolute coordinates."),
137+
category = "info",
138+
fn = report_look_target,
139+
})
140+
141+
gapi.register_action_menu_entry({
142+
id = "bn_macro_adjacent_target",
143+
name = locale.gettext("AI Adjacent Target"),
144+
description = locale.gettext("Pick an adjacent tile and print local/absolute coordinates."),
145+
category = "info",
146+
fn = report_adjacent_choice,
147+
})
65148
end
66149

67150
return action_menu_macros

0 commit comments

Comments
 (0)