diff --git a/inc/extract.lua b/inc/extract.lua index b647f50..1aa8403 100644 --- a/inc/extract.lua +++ b/inc/extract.lua @@ -73,7 +73,7 @@ end function T:initSkillData(sv) if self.skillref then return self.skillref end self.skillref = {} - local skillfull = sv.getSVEntry("SkillsFullInfo") + local skillfull = sv:getSVEntry("SkillsFullInfo") for type,lines in pairs(skillfull) do for line,skills in pairs(lines) do for skill in pairs(skills) do diff --git a/scripts/dumpSkillDataJson.lua b/scripts/dumpSkillDataJson.lua index c3235ec..99a6717 100644 --- a/scripts/dumpSkillDataJson.lua +++ b/scripts/dumpSkillDataJson.lua @@ -15,91 +15,95 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. ---- Used to extract SavedVariables +--- Used to extract set data into JSON format --- Required: /quant itr-all-skills or /quant itr-class-skills and /quant skill-full in-game ---- Required: Rserve must be running for this script ---- Edit the following to your account name to use: -local account = "@Sasky" ---- Edit server to which saved variables: "live", "liveeu", "pts" -local server = "pts" ---- +--- Required: Rserve must be ruu.nning for this script -require("inc.util") -local sv = require("inc.loadfile") -sv.loadSavedVariables(account, server) -require("inc.extract") +print("Loading libraries") +local cfg = assert(loadfile("cfg.lua"))() +local u = assert(loadfile("inc/util.lua"))() +local sv = assert(loadfile("inc/loadfile.lua"))() +local JSON = assert(loadfile "inc/JSON.lua")() -local skilldata = sv.getSVEntry("SkillsCurve") -local skillfull = sv.getSVEntry("SkillsFullInfo") +print("Account: " .. cfg.account) +print("Server: " .. cfg.server) -JSON = (loadfile "JSON.lua")() +print("Loading saved variables") +sv:loadSavedVariables(cfg.account, cfg.server) +local r = assert(loadfile "inc/extract.lua")() -local f = assert(io.open("skilldata.json", "w")) +local skilldata = sv:getSVEntry("SkillsCurve") +local skillfull = sv:getSVEntry("SkillsFullInfo") +local skillref = r:initSkillData(sv) +print("Processing raw data into fit info") local outfile = {} for skill_lvl,numbers in pairs(skilldata) do local skill = skill_lvl:gsub("..$","") local ref = skillref[skill] local data = skillfull[ref.type][ref.line][skill] - local row = { - skill, - nn(ref.type), - nn(ref.line), - 4, --Hardcoding rank 4, though possible want different ranks later - nn(data.description), - nn(data.descriptionHeader), - getMechanicName(data.mechanic), - nn(data.cost), - nn(data.targetDescription), - nn(data.minRangeCM), - nn(data.maxRangeCM), - nn(data.radiusCM), - nn(data.distanceCM), - bl(data.channeled), - nn(data.castTime), - nn(data.channelTime), - nn(data.durationMS) + local skillInfo = { + name=skill, + type=ref.type, + line=ref.line, + rank=data.rank or 4, --Hardcoding rank 4, though possible want different ranks later + description=data.description, + descriptionHeader=data.descriptionHeader, + mechanic=u.getMechanicName(data.mechanic), + cost=data.cost, + target=data.targetDescription, + minRange=data.minRangeCM, + maxRange=data.maxRangeCM, + radius=data.radiusCM, + distance=data.distanceCM, + channeled=data.channeled, + castTime=data.castTime, + channelTime=data.channelTime, + durationMS=data.durationMS, } - local DESCR = 5 - local lastFindPos = 1 local formulaNum = 1 local formulae = {} + skillInfo.fit = {} for _,rawnumbers in ipairs(numbers) do - local fit = getFitData(rawnumbers) + local fit = r:getFitData(rawnumbers) local delta = 1E-5 if fit.main < delta then fit.main = 0 end if fit.power < delta then fit.power = 0 end + if fit.health < delta then fit.health = 0 end if fit.int < delta then fit.int = 0 end - local desc = row[DESCR] + local desc = skillInfo.description local start = desc:find("|c") local _,fin = desc:find("|r") local toReplace = desc:sub(start,fin) - local formulasig = fit.main .. "/" .. fit.power .. "/" .. fit.int .. "/" .. fit.rsq + local formulasig = u.makeKey(fit.main, fit.power, fit.health, fit.int, fit.rsq) if fit.const then - row[DESCR] = replaceOne(desc, toReplace, fit.int) + skillInfo.description = r:replaceNumberInDescription(desc, toReplace, fit.int) else if not formulae[formulasig] then - table.insert(row,fit.main) - table.insert(row,fit.power) - table.insert(row,fit.health) - table.insert(row,fit.int) - table.insert(row,fit.rsq) formulae[formulasig] = "##f" .. formulaNum .. "##" + skillInfo.fit[formulasig] = { + mainCoef=fit.main, + powerCoef=fit.power, + healthCoef=fit.health, + intercept=fit.int, + rsq=fit.rsq, + } formulaNum = formulaNum + 1 end - row[DESCR] = replaceNumberInDescription(desc, toReplace, formulae[formulasig]) - end - end - for k,v in ipairs(row) do - if type(v) == "string" then - row[k] = v:gsub("[\t\n]", " ") + skillInfo.description = r:replaceNumberInDescription(desc, toReplace, formulae[formulasig]) end end - f:write(table.concat(row,"\t"),"\n") + + outfile[skill] = skillInfo end + +print("Writing results to: skilldata.json") +local f = assert(io.open("skilldata.json", "w")) +f:write(JSON:encode_pretty(outfile)) +f:close() \ No newline at end of file