Post by noncecents on Aug 18, 2017 4:56:27 GMT
I have a function that I've created to generate and execute a series of taps with very specific locations and wait times.
My intent is to generate a manualTouch actions table based upon a table of cast wait times I've imported, along with some global unit regions. I'm doing this with a for loop because the number of taps and the wait times can be variable.
However, it's not working as I intend.
It seems to just click all the buttons at once without waiting. The waits work fine when I pass them to click() though, however the click adds a delay that is too long.
What am I doing wrong? I'm fairly new to LUA so I suppose I'm missing something trivial.
My intent is to generate a manualTouch actions table based upon a table of cast wait times I've imported, along with some global unit regions. I'm doing this with a for loop because the number of taps and the wait times can be variable.
However, it's not working as I intend.
function skillCast(castdelay)
--Returns the wait action delays sorted from lowest to highest, as a number of frames to wait (60 fps is assumed).
local sortedDelayKeys = pairsByValues(castdelay, function(a, b) return a < b end)
local elapsedtime = 0
local numunits = #sb_regunit-1
--Array of unit button positions
local unitbuttonloc = {}
--the manualTouch table, with the table of actions contained within
local castorder = {
actions = {}
}
--gets locations for all of the unit buttons
for n=1, (numunits) do
unitbuttonloc[n] = Location(sb_regunit[n]:getX() + sb_regunit[n]:getW()/2, sb_regunit[n]:getY() + (sb_regunit[n]:getH()/2))
end
--goes through the sorted keys to retrieve the wait time and unit button location, inserts these into the castorder.actions table
for _, i in ipairs(sortedDelayKeys) do
waittime = ((castdelay[i] - elapsedtime) / 60)
table.insert(castorder.actions, {action = "wait", target = waittime})
table.insert(castorder.actions, {action = "touchDown", target = unitbuttonloc[i]})
table.insert(castorder.actions, {action = "touchUp", target = unitbuttonloc[i]})
elapsedtime = elapsedtime + waittime
end
--executes manualTouch using the castorder table
manualTouch(castorder)
end
It seems to just click all the buttons at once without waiting. The waits work fine when I pass them to click() though, however the click adds a delay that is too long.
What am I doing wrong? I'm fairly new to LUA so I suppose I'm missing something trivial.