-- texlua switch.lua -- 1. Stop the auto-started casual route, follow the Fast route (RestedXP) via the menu for N iterations. -- 2. Open the guide menu, click the Casual route group, click the visit for your level (and then every visit), play on. local here = arg[0]:match("^(.*)/") or "." dofile(here .. "/lib.lua") local W, ER, S, P, try, settle = H.W, H.ER, H.S, H.P, H.try, H.settle local FAST, CAS = tonumber(arg[6] or "300"), tonumber(arg[7] or "300") local function click(btn) if not btn or not btn._scripts.OnClick then return false end this = btn local ok, err = L53.xpcall(btn._scripts.OnClick, debug.traceback) if not ok then table.insert(W.errors, "[click " .. tostring(btn._name) .. "] " .. err) end return ok end local function openMenu() try("ShowGuideMenu", function() ER.ShowGuideMenu() end) end local function groupRow(pred) for i = 1, 6 do local r = _G["pfQuest_xpGuideGuideMenuGroup" .. i]; if r and r.grp and r._shown and pred(r.grp.name) then return r end end end local function guideRows() local t = {} for i = 1, 22 do local r = _G["pfQuest_xpGuideGuideMenuGuide" .. i]; if r and r.guide and r._shown then table.insert(t, r) end end return t end -- Phase 1: the fast route openMenu() local fast = groupRow(function(n) return n ~= ER.ROUTE_GROUP end) if fast then click(fast) local rows = guideRows() -- the guide the menu marks best, else the first local pick = rows[1] local best for _, g in ipairs(S.Suggest()) do if not g.route then best = g break end end for _, r in ipairs(rows) do if r.guide == best then pick = r end end if pick then click(pick) end end P("fast: " .. tostring(S.Info() and S.Info().name)) PLAY(FAST) P("after fast: level " .. W.level .. ", log " .. #W.log .. ", " .. tostring(S.Info() and S.Info().name)) -- Phase 2: switch to the casual route from the menu openMenu() local cas = groupRow(function(n) return n == ER.ROUTE_GROUP end) if not cas then P("NO CASUAL GROUP IN MENU") else click(cas) local rows = guideRows() P("casual rows: " .. #rows) -- the visit that fits the level local fit = ER.RouteVisitFor(W.level) local chosen for _, r in ipairs(rows) do if r.guide == fit then chosen = r end end if chosen then click(chosen) else P("fitting visit not in menu") end P("casual: " .. tostring(S.Info() and S.Info().name) .. " pos " .. S.Position() .. "/" .. S.Count()) PLAY(CAS) -- click every visit of the route once and run a few iterations on each openMenu(); cas = groupRow(function(n) return n == ER.ROUTE_GROUP end); click(cas) for i, r in ipairs(guideRows()) do openMenu(); click(groupRow(function(n) return n == ER.ROUTE_GROUP end)) local rr = guideRows()[i] if rr then click(rr); PLAY(15) end end end -- and every guide of every group, a few iterations each for gi = 1, 6 do openMenu() local g = _G["pfQuest_xpGuideGuideMenuGroup" .. gi] if g and g.grp and g._shown then click(g) local n = #guideRows() for i = 1, n do openMenu(); click(_G["pfQuest_xpGuideGuideMenuGroup" .. gi]); local rr = guideRows()[i] if rr then click(rr); PLAY(5) end end end end REPORT()