Adding autoresearch

This commit is contained in:
Matt Wagner 2021-09-29 11:24:07 -07:00
parent 07e6752229
commit f5b8e6c04a
6 changed files with 244 additions and 0 deletions

View File

@ -0,0 +1,7 @@
[
{
"name": "autoresearch",
"regex": "^autoresearch( ?.*)$",
"script": "lotj.autoResearch.command(matches[2])"
}
]

View File

@ -0,0 +1,69 @@
lotj = lotj or {}
lotj.autoResearch = lotj.autoResearch or {}
function lotj.autoResearch.log(text, precedingNewline)
if precedingNewline then
echo("\n")
end
cecho("[<cyan>LOTJ AutoResearch<reset>] "..text.."\n")
end
function lotj.autoResearch.command(args)
argList = splitargs(args)
if #argList == 1 and argList[1] == "start" then
lotj.autoResearch.enabled = true
lotj.autoResearch.researchList = {}
lotj.autoResearch.log("Research list cleared.")
enableTrigger("autoresearch.grabSkills")
lotj.autoResearch.log("Retrieving research list...")
send("practice", false)
elseif #argList == 1 and argList[1] == "next" then
if #(lotj.autoResearch.researchList or {}) == 0 then
lotj.autoResearch.log("Research list empty.")
lotj.autoResearch.enabled = false
return
end
table.remove(lotj.autoResearch.researchList, 1)
expandAlias("autoresearch continue", false)
elseif #argList == 1 and argList[1] == "continue" then
if #(lotj.autoResearch.researchList or {}) == 0 then
lotj.autoResearch.log("Research list empty.")
lotj.autoResearch.enabled = false
return
end
local current = lotj.autoResearch.initialCount - #lotj.autoResearch.researchList + 1
lotj.autoResearch.log(current.."/"..lotj.autoResearch.initialCount..": Researching "..lotj.autoResearch.researchList[1].."...")
send("research "..lotj.autoResearch.researchList[1], false)
elseif #argList == 1 and argList[1] == "stop" then
lotj.autoResearch.enabled = false
lotj.autoResearch.researchList = {}
lotj.autoResearch.log("Research list cleared.")
else
lotj.autoResearch.log("AutoResearch Command List\n")
cecho([[
<yellow>autoresearch start<reset>
Get the practice list and automatically begin researching anything eligible for it. Must be in a library.
<yellow>autoresearch continue<reset>
Resume researching the first skill in the current autoresearch list.
<yellow>autoresearch next<reset>
Skip to the next skill in the autoresearch list and begin researching it.
<yellow>autoresearch stop<reset>
Clear the autoresearch list and disable triggers for continuing automatically.
]])
end
end

View File

@ -0,0 +1,5 @@
[
{
"name": "autoresearch"
}
]

View File

@ -0,0 +1,19 @@
for str in matches[1]:gmatch("[^%%]+%s*") do
str = str:gsub('^%s*(.-)%s*$', '%1') -- Trim whitespace
local skill, pct = str:match("(.*)%s+([0-9]+)")
if skill then
skill = skill:gsub('^%s*(.-)%s*$', '%1') -- Trim whitespace
pct = tonumber(pct)
if pct < 90 then
if skill == "research" then
-- Always do research first if it's in the list
table.insert(lotj.autoResearch.researchList, 1, skill)
else
table.insert(lotj.autoResearch.researchList, skill)
end
end
end
end
setTriggerStayOpen("autoresearch.grabSkills", 1)

View File

@ -0,0 +1,14 @@
if lotj.autoResearch.startOnPracticeEnd then
lotj.autoResearch.startOnPracticeEnd = false
echo("\n")
lotj.autoResearch.initialCount = #(lotj.autoResearch.researchList or {})
if lotj.autoResearch.initialCount == 0 then
lotj.autoResearch.enabled = false
lotj.autoResearch.log("Nothing to research.")
return
end
lotj.autoResearch.log("Don't forget to 'bot start' if you won't be monitoring your screen as this runs.")
expandAlias("autoresearch continue", false)
else
lotj.autoResearch.log("Type 'autoresearch start' to start researching all skills below 90%.", true)
end

View File

@ -0,0 +1,130 @@
[
{
"name": "autoresearch.grabSkills",
"isActive": "no",
"fireLength": 1,
"patterns": [
{
"pattern": "^-+Skills -+$",
"type": "regex"
}
],
"children": [
{
"name": "autoresearch.grabSkills.skillLine",
"patterns": [
{
"pattern": "^\\s*[^%]+ +[0-9]+%.*$",
"type": "regex"
}
]
},
{
"name": "autoresearch.grabSkills.weaponsLine",
"patterns": [
{
"pattern": "^-+Weapons-+$",
"type": "regex"
}
],
"script": "setTriggerStayOpen(\"autoresearch.grabSkills\", 1)"
},
{
"name": "autoresearch.grabSkills.featsLine",
"patterns": [
{
"pattern": "^-+ Feats -+$",
"type": "regex"
}
],
"script": "lotj.autoResearch.startOnPracticeEnd = true; disableTrigger(\"autoresearch.grabSkills\")"
}
]
},
{
"name": "autoresearch.next",
"patterns": [
{
"pattern": "^You search and search but can't find that information.$",
"type": "regex"
},
{
"pattern": "^You can't learn about that in books. Go find a teacher.$",
"type": "regex"
},
{
"pattern": "^You can't learn any more about that from books!$",
"type": "regex"
},
{
"pattern": "^You can't learn smuggling skills from a book!$",
"type": "regex"
},
{
"pattern": "^You aren't going to learn that from a book. Go find a Wookiee!$",
"type": "regex"
},
{
"pattern": "^You can't learn bounty hunting skills from a book!$",
"type": "regex"
},
{
"pattern": "^Go learn it the hard way, sissy.$",
"type": "regex"
},
{
"pattern": "^You're not going to learn force spells from a book. Trust me.$",
"type": "regex"
},
{
"pattern": "^You cannot learn more about that from books.$",
"type": "regex"
}
],
"script": "if lotj.autoResearch.enabled then echo(\"\\n\"); expandAlias(\"autoresearch next\", false) end"
},
{
"name": "autoresearch.continue",
"patterns": [
{
"pattern": "^You finish your studies and feel much more skilled.$",
"type": "regex"
},
{
"pattern": "^You study for hours on end, but fail to gather any knowledge.$",
"type": "regex"
}
],
"script": "if lotj.autoResearch.enabled then echo(\"\\n\"); expandAlias(\"autoresearch continue\", false) end"
},
{
"name": "autoresearch.interrupted",
"patterns": [
{
"pattern": "^You are interrupted and fail to finish your studies...$",
"type": "regex"
}
],
"script": "if lotj.autoResearch.enabled then lotj.autoResearch.log(\"Type 'autoresearch continue' to pick up where you left off.\", true) end"
},
{
"name": "autoresearch.practiceEnd",
"patterns": [
{
"pattern": "^To see a shorter practice list, type PRACTICE <class name>.$",
"type": "regex"
}
]
}
]