@@ -10,17 +10,13 @@ local world = df.global.world
1010local map = world .map
1111local you = world .units .adv_unit
1212local delayFrames = 10 -- frames to wait for each simulated step
13+ local pathGoal = 215 -- unit_path_goal value used for adventure movement
1314
1415script .start (function ()
1516 if not you then
1617 qerror (" Error: No adventurer unit found." )
1718 end
1819
19- local view = dfhack .gui .getCurViewscreen ()
20- if not view then
21- qerror (" Error: No current viewscreen to send input to." )
22- end
23-
2420 local x , y , current_z = you .pos .x , you .pos .y , you .pos .z
2521
2622 -- Show Up/Down/Cancel menu
@@ -69,11 +65,26 @@ script.start(function()
6965 return
7066 end
7167
68+ local view = dfhack .gui .getCurViewscreen ()
69+ if not view then
70+ dfgui .showPopupAnnouncement (
71+ " Auto-path failed: no valid viewscreen to send input to." ,
72+ COLOR_RED
73+ )
74+ return
75+ end
76+
77+ if you .path .path then
78+ you .path .path .x :resize (0 )
79+ you .path .path .y :resize (0 )
80+ you .path .path .z :resize (0 )
81+ end
82+
7283 -- Request path to (x, y, z)
7384 you .path .dest .x = x
7485 you .path .dest .y = y
7586 you .path .dest .z = z
76- you .path .goal = 215
87+ you .path .goal = pathGoal
7788
7889 -- Simulate the OPTION1 input (one-step move)
7990 gui .simulateInput (view , ' OPTION1' )
@@ -85,7 +96,7 @@ script.start(function()
8596 if valid then
8697 -- Commit to this step
8798 you .path .dest .z = z
88- you .path .goal = 215
99+ you .path .goal = pathGoal
89100 local levels = math.abs (z - current_z )
90101 dfgui .showPopupAnnouncement (
91102 string.format (" Auto-path %s %d levels." , direction , levels ),
0 commit comments