Created
April 2, 2020 22:40
-
-
Save Connicpu/ebfc8d36bb5a21640a9c0535ec95395d to your computer and use it in GitHub Desktop.
Idle Skilling script for auto-grinder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function nextChar(state, curr) | |
if curr == nil then | |
return state[1] | |
end | |
local byte = string.byte(curr, 1) | |
if byte < state[2] then | |
return string.char(byte + 1) | |
end | |
end | |
return function(first, last) | |
return nextChar, { first, string.byte(last, 1) }, nil | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
positionMode = "fixedAspect", | |
fixedAspectRatio = { 16, 9 }, | |
tasks = { | |
{ | |
name = "Tinkering", | |
entryPoint = "tinkering", | |
paramters = { | |
{ "Target Bonus", "number", 3000, "Script will keep tinkering until this number is reached." }, | |
{ "Max Tries", "number", 0, "Maximum number of tinkering attempts, 0 means until target is reached." }, | |
{ "Upgrades", "number", 10, "Number of times to try upgrading. A margin may be helpful in case of game slowness." }, | |
} | |
}, | |
{ | |
name = "Spelunking", | |
entryPoint = "spelunking", | |
parameters = { | |
{ "Bag Taps", "number", 3, "Number of times to try tapping the bag per half-cycle" }, | |
{ "Spelunk Time", "number", 3000, "Target number of milliseconds between Jump/Extract. May go over if trying to manage many spelunkers." }, | |
{ "Spelunker A Dig", "boolean", true, "Whether spelunker A should dig" }, | |
{ "Spelunker B Dig", "boolean", true, "Whether spelunker B should dig" }, | |
{ "Spelunker C Dig", "boolean", true, "Whether spelunker C should dig" }, | |
{ "Spelunker D Dig", "boolean", true, "Whether spelunker D should dig" }, | |
{ "Spelunker E Dig", "boolean", true, "Whether spelunker E should dig" }, | |
{ "Spelunker F Dig", "boolean", true, "Whether spelunker F should dig" }, | |
{ "Spelunker G Dig", "boolean", true, "Whether spelunker G should dig" }, | |
{ "Spelunker H Dig", "boolean", true, "Whether spelunker H should dig" }, | |
{ "Enable Learning", "boolean", false, "Manage learning on the rest of your spelunkers" }, | |
{ "Learning Target", "number", 14, "Target level to absorb at", "Enable Learning" }, | |
{ "Spelunker A Has Canary?", "boolean", false, "Enable Learning" }, | |
{ "Spelunker B Has Canary?", "boolean", false, "Enable Learning" }, | |
{ "Spelunker C Has Canary?", "boolean", false, "Enable Learning" }, | |
{ "Spelunker D Has Canary?", "boolean", false, "Enable Learning" }, | |
{ "Spelunker E Has Canary?", "boolean", false, "Enable Learning" }, | |
{ "Spelunker F Has Canary?", "boolean", false, "Enable Learning" }, | |
{ "Spelunker G Has Canary?", "boolean", false, "Enable Learning" }, | |
{ "Spelunker H Has Canary?", "boolean", false, "Enable Learning" }, | |
} | |
} | |
}, | |
markers = { | |
tinkering = { | |
{ "click", "Reset Button" }, | |
{ "click", "Reset Confirm" }, | |
{ "click", "Upgrade/Go Back" }, | |
{ "region", "Upgrade Value" }, | |
}, | |
spelunking = { | |
{ "click", "Jump/Extract" }, | |
{ "click", "Absorb" }, | |
{ "click", "Super Absorb" }, | |
{ "click", "Bag" }, | |
{ "click", "Spelunker A" }, | |
{ "click", "Spelunker B" }, | |
{ "click", "Spelunker C" }, | |
{ "click", "Spelunker D" }, | |
{ "click", "Spelunker E" }, | |
{ "click", "Spelunker F" }, | |
{ "click", "Spelunker G" }, | |
{ "click", "Spelunker H" }, | |
{ "region", "Spelunker A Learn Level" }, | |
{ "region", "Spelunker B Learn Level" }, | |
{ "region", "Spelunker C Learn Level" }, | |
{ "region", "Spelunker D Learn Level" }, | |
{ "region", "Spelunker E Learn Level" }, | |
{ "region", "Spelunker F Learn Level" }, | |
{ "region", "Spelunker G Learn Level" }, | |
{ "region", "Spelunker H Learn Level" }, | |
} | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
tinkering = require('tinkering.lua') | |
spelunking = require('spelunking.lua') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local struct = require('struct.lua') | |
local charRange = require('charRange.lua') | |
local Spelunker = struct() | |
function Spelunker:__init(state, name, params, markers) | |
self.state = state | |
self.name = name | |
self.digging = params[name..' Dig'] | |
self.hasCanary = params[name..' Has Canary?'] | |
self.selectBtn = markers:find('spelunking', name) | |
self.learnLvl = markers:find('spelunking', name..' Learn Level') | |
end | |
function Spelunker:select() | |
if self.state.selected ~= self.name then | |
self.state.selected = self.name | |
self.selectBtn:click() | |
self.state:delay(100) | |
end | |
end | |
function Spelunker:dig() | |
self:select() | |
self.state.jumpBtn:click() | |
self.state:delay(100) | |
for i = 1, self.state.bagTaps do | |
self.state.bagBtn:click() | |
self.state:delay(100) | |
end | |
end | |
function Spelunker:learn() | |
self:select() | |
if self.hasCanary then | |
self.state.superAbsorbBtn:click() | |
self.state:delay(100) | |
end | |
self.state.absorbBtn:click() | |
self.state:delay() | |
end | |
function Spelunker:learnLevel() | |
return self.learnLvl:ocr('number') | |
end | |
local Spelunking = struct() | |
function Spelunking:__init(params, markers) | |
self.learningEnabled = params['Enable Learning'] | |
self.learningTarget = params['Learning Target'] | |
self.bagTaps = params['Bag Taps'] | |
self.cyclesSinceLearning = 0 | |
self.cycleTime = | |
self.selected = nil | |
self.diggers = {} | |
self.learners = {} | |
self.spelunkers = {} | |
self.jumpBtn = markers:find('spelunking', 'Jump/Extract') | |
self.absorbBtn = markers:find('spelunking', 'Absorb') | |
self.superAbsorbBtn = markers:find('spelunking', 'Super Absorb') | |
self.bagBtn = markers:find('spelunking', 'Bag') | |
-- Init base params of the spelunkers | |
for c in charRange('A', 'H') do | |
local name = 'Spelunker '..c | |
local spelunker = Spelunker(self, name, params, markers) | |
self.spelunkers[name] = spelunker | |
if spelunker.digging then | |
table.insert(self.diggers, name) | |
else | |
table.insert(self.learners, name) | |
end | |
end | |
end | |
function Spelunking:delay(ms) | |
self.cycleTime = self.cycleTime + ms | |
ag.delay(ms) | |
end | |
local CYCLE_TARGET = 3000 | |
function Spelunking:endCycle() | |
local remainder = CYCLE_TARGET - self.cycleTime | |
if remainder > 0 then | |
ag.delay(remainder) | |
end | |
self.cycleTime = 0 | |
end | |
function Spelunking:digCycle() | |
self.cyclesSinceLearning = self.cyclesSinceLearning + 1 | |
for i, name in ipairs(self.diggers) do | |
self.spelunkers[name]:dig() | |
end | |
end | |
function Spelunking:shouldCheckLearning() | |
return self.learningEnabled and self.cyclesSinceLearning >= 60 | |
end | |
function Spelunking:checkLearning() | |
self.cyclesSinceLearning = 0 | |
for i, name in ipairs(self.learners) do | |
local spelunker = self.spelunkers[name] | |
local target self.learningTarget | |
if spelunker:learnLevel() >= target then | |
spelunker:learn() | |
end | |
end | |
end | |
return function(params, markers) | |
local state = Spelunking(params, markers) | |
while true do | |
state:digCycle() | |
if state:shouldCheckLearning() then | |
state:checkLearning() | |
end | |
state:endCycle() | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return function() | |
local c = {} | |
c.__index = c | |
local mt = {} | |
function mt.__call(c, ...) | |
local obj = {} | |
if c.__init then c.__init(obj, ...) end | |
return setmetatable(obj, c) | |
end | |
setmetatable(c, mt) | |
return c | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return function(params, markers) | |
local mreset = markers:find("tinkering", "Reset Button") | |
local mconfirm = markers:find("tinkering", "Reset Confirm") | |
local mupgrade = markers:find("tinkering", "Upgrade/Go Back") | |
local mvalue = markers:find("tinkering", "Upgrade Value") | |
local targetValue = params['Target Bonus'] | |
local maxTries = params['Max Tries'] | |
local upgradeTimes = params['Upgrades'] | |
local attempts = 0 | |
while mvalue:ocr('number') < targetValue do | |
mreset:click() | |
ag.delay(100) | |
mconfirm:click() | |
ag.delay(100) | |
for i = 1, upgradeTimes * 2 do | |
mupgrade:click() | |
ag.delay(100) | |
end | |
attempts = attempts + 1 | |
if maxTries > 0 and attempts >= maxTries then | |
ag.stop() | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Im brand new to autoscripting and coding.....how does one take this code and run it on Idle skilling? I tried figureing it out but i honestly dont know where to start