John Smith commited on 2022-301 23:19:28
Showing 1 changed files, with 21 additions and 3 deletions.
The leech-search feature added in 2daca72 now outputs prompt indices of the form card:prompt, which can be used as arguments to a suspension procedure (run with "t" option).
| ... | ... |
@@ -142,7 +142,7 @@ end |
| 142 | 142 |
local action = nil |
| 143 | 143 |
if arg[1] then |
| 144 | 144 |
local fc = arg[1]:sub(1, 1) |
| 145 |
- if fc == "a" or fc == "h" or fc == "l" or fc == "r" or fc == "s" then |
|
| 145 |
+ if fc == "a" or fc == "h" or fc == "l" or fc == "r" or fc == "s" or fc == "t" then |
|
| 146 | 146 |
action = fc |
| 147 | 147 |
else |
| 148 | 148 |
action = "h" |
| ... | ... |
@@ -244,7 +244,7 @@ if action == "a" then |
| 244 | 244 |
-- Help |
| 245 | 245 |
elseif action == "h" then |
| 246 | 246 |
io.write(string.format( |
| 247 |
- "Usage: %s ACTION\n\nACTION may be one of\n\t(a)dd card\n\t(h)elp\n\t(l)eech search\n\t(r)eview session\n\t(s)tatistics\n", |
|
| 247 |
+ "Usage: %s ACTION\n\nACTION may be one of\n\t(a)dd card\n\t(h)elp\n\t(l)eech search\n\t(r)eview session\n\t(s)tatistics\n\t(t)erminate (suspend) prompt\n", |
|
| 248 | 248 |
arg[0] |
| 249 | 249 |
)) |
| 250 | 250 |
-- Leech search |
| ... | ... |
@@ -264,7 +264,7 @@ elseif action == "l" then |
| 264 | 264 |
end) |
| 265 | 265 |
io.write(string.format("Detected %d leeches:\n", #leechqueue))
|
| 266 | 266 |
for _, ij in ipairs(leechqueue) do |
| 267 |
- io.write(string.format("%s\n", deck[ij[1]][ij[2]]))
|
|
| 267 |
+ io.write(string.format("%d:%d %s\n", ij[1], ij[2], deck[ij[1]][ij[2]]))
|
|
| 268 | 268 |
end |
| 269 | 269 |
else |
| 270 | 270 |
io.write("Failed to load deck\n")
|
| ... | ... |
@@ -378,6 +378,24 @@ elseif action == "r" then |
| 378 | 378 |
-- Statistics |
| 379 | 379 |
elseif action == "s" then |
| 380 | 380 |
-- TODO |
| 381 |
+elseif action == "t" then |
|
| 382 |
+ local ip |
|
| 383 |
+ if arg[2] then |
|
| 384 |
+ local a, b = arg[2]:match("(%d+):(%d+)")
|
|
| 385 |
+ if a and b then |
|
| 386 |
+ ip = { a, b }
|
|
| 387 |
+ end |
|
| 388 |
+ end |
|
| 389 |
+ if not ip then |
|
| 390 |
+ io.write("Bad prompt index (must be cardnum:promptnum)\n")
|
|
| 391 |
+ end |
|
| 392 |
+ deck = loader.load(deckfname, config) |
|
| 393 |
+ if deck then |
|
| 394 |
+ deck[ip[1]][ip[2]].delay = -deck[ip[1]][ip[2]].delay |
|
| 395 |
+ loader.save(deckfname, deck) |
|
| 396 |
+ else |
|
| 397 |
+ io.write("Failed to load deck\n")
|
|
| 398 |
+ end |
|
| 381 | 399 |
else |
| 382 | 400 |
io.write "unreachable" |
| 383 | 401 |
end |
| 384 | 402 |