-- Plant/Harvest Script v1.51 -- ToDo -- pixel color to detect valid harvesting situation not working -- clean up console messages -- v1.51 -- changes - cleanup messages -- add - endless plant/harvest mode around char -- v1.5 -- add - claim spot mode (places your design at a place and press the confirmation button) -- change - little bug in detecting chat mode / also know able to deactivate chat interruption -- add - pixel color check for harvesting notice ... but still not working -- v1.41 -- add - script timer -- change - use keyboard.virtualType to spam messages -- v1.4 -- minor changes -- spam message mode -- v1.31 -- separate tuning factor for x & y -- Test key will show cursor position -- some little bugs in calcuation of distance between rows -- v1.3 -- add new key to toggle 'move during harvest' on/off -- add option to tune x/y distance depending from distance while planting -- v1.2 -- add anti afk timer in idle mode -- add key to increase/decrease x/y distance values between planting spots -- set high max harvest spam value for harvest without moving -- use planting sets for various values at differen field situations/plant -- credis to Lisa, I used your harvesting script as template -- --------------------------------------------------------------- -- Hints: -- you need to change the parameters depening from your field-size, your plants, your viewpoint -- -- don't use plant mode unattanded in the wild. You could easily be disturbed by other players -- and by that being detected as a bot user. -- planting speed: 11-13 plants/minute -- change planting parameters to your needs paraset = {} paraset[1]={ -- ~360 plants until first 3 rows are ripe _setname = "Big Field with Azalee", -- just a name for that plant setting _start_x = 20, -- start planting relative from window x value _start_y = 60, -- start planting relative from window y value _dist_x = 45, -- space between columns (depending from your view/distance to your char) _dist_y = 23, -- space between rows (depending from your view/distance to your char) _columns = 33, -- how many columns to plant _tuneColumn = 1.2, -- factor to reduce number of colums if rows are closer _rows = 12, -- how many rows to plant _rnd_add_x = 4, -- max random add to x value _rnd_add_y = 4, -- max random add to y value _tuningx = 1.18, -- tune x distance exponential if rows are closer to players character -- measure row 1: x~40 y~19 => tune 1.0 => 1.1 -- measure row 12 x~52 y~42 => tune 1.9 => 2.0 _tuningy = 1.95, -- tune y distance depending from distance while planting _plantPauseTimer = 0, -- time between next plant round while endless plant/harvesting _usePlantOffset = true, -- offset each row for half x value } paraset[2]={ _setname = "8x8 Ginger/Azalee", -- just a name for that plant setting _start_x = 805, -- start planting relative from window x value _start_y = 122, -- start planting relative from window y value -- dist 80 would be enough, but > is better to correct problems _dist_x = 72, -- space between columns (depending from your view/distance to your char) _dist_y = 72, -- space between rows (depending from your view/distance to your char) _columns = 6, -- how many columns to plant _tuneColumn = 0.0, -- factor to reduce colums if rows are closer _rows = 6, -- how many rows to plant _rnd_add_x = 0, -- max add to x value _rnd_add_y = 0, -- max add to y value _tuningx = 0.0, -- tune x distance depending from distance while planting _tuningy = 0.0, -- tune y distance depending from distance while planting _plantPauseTimer = 0, -- time between next plant round while endless plant/harvesting _usePlantOffset = false, -- offset each row for half x value } paraset[3]={ -- stand exactliy at point 8 _setname = "16x16 Ginger", -- just a name for that plant setting _start_x = 520, -- start planting relative from window x value _start_y = 100, -- start planting relative from window y value _dist_x = 70, -- space between columns (depending from your view/distance to your char) _dist_y = 70, -- space between rows (depending from your view/distance to your char) _columns = 13, -- how many columns to plant _tuneColumn = 0.0, -- factor to reduce colums if rows are closer _rows = 7, -- how many rows to plant _rnd_add_x = 0, -- max add to x value _rnd_add_y = 0, -- max add to y value _tuningx = 0.0, -- tune x distance depending from distance while planting _tuningy = 0.0, -- tune y distance depending from distance while planting _plantPauseTimer = 0, -- time between next plant round while endless plant/harvesting _usePlantOffset = false, -- offset each row for half x value } paraset[4]={ _setname = "around char small plant", -- just a name for that plant setting _start_x = 820, -- start planting relative from window x value _start_y = 406, -- start planting relative from window y value -- dist 80 would be enough, but > is better to correct problems _dist_x = 70, -- space between columns (depending from your view/distance to your char) _dist_y = 66, -- space between rows (depending from your view/distance to your char) _columns = 6, -- how many columns to plant _tuneColumn = 0.0, -- factor to reduce colums if rows are closer _rows = 5, -- how many rows to plant _rnd_add_x = 0, -- max add to x value _rnd_add_y = 0, -- max add to y value _tuningx = 0.0, -- tune x distance depending from distance while planting _tuningy = 0.0, -- tune y distance depending from distance while planting _plantPauseTimer = 300, -- time between next plant round while endless plant/harvesting | gherkin ~330 _usePlantOffset = true, -- offset each row for half x value } local _move_for_harvest = true -- choose if you want to move after x harvesting trys at one spot local _move_times = 7 -- how often we move harvesting spot until pause local _move_time = 760 -- how many ms we move forward between harvesting spots local _harvest_spam = 52 -- how often we spam harvest key at one place (reduce it if you have less plants at one spot) -- 50 for 3 rows -- change pixel color and check position for harvesting notive 'F' here local _checkHarvestPixel = false -- false/true check pixel color or just use counter _harvest_spam ? local _harvestNoticeX = 963 -- where to check pixel color of F (harvest info) local _harvestNoticeY = 773 -- where to check pixel color of F (harvest info) local harvestColors = {} harvestColors[1] = "18114" -- green F harvestColors[2] = "15143" -- reaping hook -- change key settings to your needs local _chatKey = false; -- false or key.VK_ENTER / to stop because of starting chat - default key.VK_ENTER local _plantKey = key.VK_Y; -- drop your seeds to that key at the UI (or change the key) local _harvestKey = key.VK_F; -- Interaction key, "F" is default. local _forwardKey = key.VK_W -- move forward key local _toggle_moveKey = key.VK_F1 -- toggle move during harvest on/off local _incXvalueKey = key.VK_F5 -- increase x value between plant spots (between columns) local _decXvalueKey = key.VK_F6 -- decrease x value between plant spots (between columns) local _incYvalueKey = key.VK_F7 -- increase y value between plant spots (between rows) local _decYvalueKey = key.VK_F8 -- decrease y value between plant spots (between rows) local _switchPlantSetKey = key.VK_F4 -- switch between planting sets local _toggleKey = key.VK_F10; -- toggle between different modes: plant/harvest/spam ... local _pauseKey = key.VK_F11; -- Change to any hotkey you would like. local _antiafkKey = key.VK_END -- press that key to avoid afk local _testKey = key.VK_T; -- test case -- spam mode parameters local _spamTimerMin = 120 -- message timer in seconds minimum (default 120) local _spamTimerMax = 180 -- message timer in seconds maximum (default 180) spamMsg = {} -- spamMsg[1] = "/fr WTB 16x16 garden in non PVP area with scarecrow /w me your price" -- spamMsg[2] = "/fr WTB 16x16 garden pls /w me your price. Non PVP area please" spamMsg[1] = "/s Hi" spamMsg[2] = "/s Huhu" -- Claim Spot/Land Mode parameters local _useDesignKey = key.VK_5; local _spotMouseX = 486 -- change the values for you need local _spotMouseY = 386 -- change the values for you need local _confirmButtonX = 913 -- change the values for you need local _confirmButtonY = 761 -- change the values for you need -- endless Planting/Harvest Mode parameters -- normaly no change needed local _scriptMaxRuntime = 600 -- minutes - max runing time of script in minutes local _afkTimerMin = 600 -- seconds - anti-afk timer in seconds minimum (is 5 min aft, 20 min logout) local _afkTimerMax = 840 -- seconds - anti-afk timer in seconds maximum local _rnd_add_plant = 400 -- ms - max add to planting time in ms local _rnd_add_harvest = 200 -- ms - max add to harvesting time in ms local _plantCooldown = 1.35 -- seconds - (key&mousepress will produce additional waiting time) you need > 2 sec all together -- possible modes HARVEST_MODE = 1 PLANT_MODE = 2 SPAM_MODE = 3 CLAIMSPOT_MODE = 4 PLANTENDLESS_MODE = 5 -- working fields local hf_column = 1 local hf_row = 1 local hf_lastActionTime = time.getNow() local scriptStartTime = time.getNow() local hf_rnd_add_x = 0 -- max add to x value local hf_rnd_add_y = 0 -- max add to y value local hf_rnd_add_plant = math.random(_rnd_add_plant) -- max add to planting time local hf_rnd_add_harvest = math.random(_rnd_add_harvest) -- max add to harvesting time local hf_plantPauseTimer = 0 -- time between next plant round local hf_harvest_spam = _harvest_spam -- max harvest spam value local hf_harvest_count = 0 local hf_afkTimer = _afkTimerMin -- for calulating new spam for every message rnd local hf_spamMsgTimer = _spamTimerMin -- for calulating new spam for every message rnd local hf_move_count = 0 local activeSet = 0 -- active planting value set local activeMode = 1 -- active Mode 1=harvest/2=plant/3=spam msg local activeSpamMsg = 1 local lastxPosition = 0 -- remember last x position from planting spot to add x values local subMode = "" -- active submmode -- active planting set variables local _start_x, _start_y, _dist_x, _dist_y, _columns, _rows, _rnd_add_x, _rnd_add_y, _tuningx, _tuningy, _tuneColumn, _plantPauseTimer, _usePlantOffset -- Don't modify these local win local running = false; local chatpause = false local targetWindowClass = "ArcheAge"; local targetWindowName = "- ArcheAge*- *"; local useVirtualType = false local wx,wy,wwide,whigh; -- Main script function macro.init() win = window.find(targetWindowName, targetWindowClass); if( not win ) then error("Could not find ArcheAge window. You must have the game running to use this script.\n", 0); end wx,wy,wwide,whigh = window.getRect(win); -- check if keyboard.virtualType function available local version = string.gsub(macro.getVersion(),"(%d+)%.(%d+)%.(%d+)","%1%2%3") if tonumber(version) >= 1921 then useVirtualType = true else useVirtualType = false end if _move_for_harvest then hf_harvest_spam = _harvest_spam -- set max value for spaming harvest key else hf_harvest_spam = 999999 -- spam harvest key endless end if _move_for_harvest then hf_string = "true" else hf_string = "false" end SwitchPlantingSet() PrintActivePlantingValues() printf("Harvest mode: move active="..hf_string.." / move ".._move_times.."x for ".._move_time.."ms. Spam harvest key "..hf_harvest_spam.." times.\n"); printf("Your harvest key: "..keyboard.getKeyName(_harvestKey).." \n"); printf("Put your seeds on UI field with key: "..keyboard.getKeyName(_plantKey).." \n"); printf("Press "..keyboard.getKeyName(_switchPlantSetKey).." to load next planting set.\n") printf("Press "..keyboard.getKeyName(_incXvalueKey).."/"..keyboard.getKeyName(_decXvalueKey).." to increase/decrease distance x between planting columns.\n"); printf("Press "..keyboard.getKeyName(_incYvalueKey).."/"..keyboard.getKeyName(_decYvalueKey).." to increase/decrease distance y between planting rows.\n"); printf("Press "..keyboard.getKeyName(_toggleKey).." to toggle between modes: plant/harvest/spam messages.\n") printf("Press "..keyboard.getKeyName(_toggle_moveKey).." to toggle between move during harves true/false.\n") printf("Press Ctrl+L to leave script\n"); printf("Active mode: "..ModeToString(activeMode).."\n") printf("Press "..keyboard.getKeyName(_pauseKey).." to start/pause.\n"); end function macro.main(dt) --printf("Here in main"..math.random(100).."\n") if ( activeMode == PLANT_MODE or activeMode == PLANTENDLESS_MODE ) and running then if subMode == "pause" then checkPlantingPauseFinished() else if Planting() then -- we try to plant something PlantingSetNextSpot() end end end if activeMode == HARVEST_MODE and running then Harvest() -- press harvest key HarvestMoveSpot() -- check if to move forward / change spot end if activeMode == SPAM_MODE and running then SpamMessage() end if activeMode == CLAIMSPOT_MODE and running then ClaimSpot() end if not running then -- avoid afk AntiAfk() end CheckRuntime() end function macro.event(e, data1, data2) if( e == "keypressed" ) then if( data1 == _pauseKey ) then if running then running = false printf("Pausing script. Press "..keyboard.getKeyName(_pauseKey).." to resume script\n") else running = true printf("Resume script. Press "..keyboard.getKeyName(_pauseKey).." to pause script\n") end end if( data1 == _toggleKey ) then activeMode = activeMode + 1 if activeMode > 5 then activeMode = 1 end hf_move_count = 0 hf_harvest_count = 0 running = false printf("Press "..keyboard.getKeyName(_toggleKey).." to toggle mode. Active mode: "..ModeToString(activeMode).." Press "..keyboard.getKeyName(_pauseKey).." to start...\n") end if( data1 == _chatKey ) then if chatpause then chatpause = false print("\nChat pause ended. Continuing since you finished chating.") running = true system.rest(1000); -- need some rest to finish chat line to avoid going move forward to chat line else chatpause = true print("\nChat pause! Waiting until you hit enter again before continuing") running = false end end if( data1 == _incXvalueKey ) then _dist_x = _dist_x + 1 printf("Distance between columns: ".. _dist_x..". Press "..keyboard.getKeyName(_incXvalueKey).." to increase or "..keyboard.getKeyName(_decXvalueKey).." to decrease x value.\n"); end if( data1 == _decXvalueKey ) then _dist_x = _dist_x - 1 printf("Distance between columns: ".. _dist_x..". Press "..keyboard.getKeyName(_incXvalueKey).." to increase or "..keyboard.getKeyName(_decXvalueKey).." to decrease x value.\n"); end if( data1 == _incYvalueKey ) then _dist_y = _dist_y + 1 printf("Distance between rows: ".. _dist_y..". Press "..keyboard.getKeyName(_incYvalueKey).." to increase or "..keyboard.getKeyName(_decYvalueKey).." to decrease y value.\n"); end if( data1 == _decYvalueKey ) then _dist_y = _dist_y - 1 printf("Distance between rows: ".. _dist_y..". Press "..keyboard.getKeyName(_incYvalueKey).." to increase or "..keyboard.getKeyName(_decYvalueKey).." to decrease y value.\n"); end if( data1 == _switchPlantSetKey ) then SwitchPlantingSet(activeSet) PrintActivePlantingValues() end -- toggle move to harvest true/false if( data1 == _toggle_moveKey ) then if _move_for_harvest then _move_for_harvest = false hf_harvest_spam = 999999 -- spam harvest key endless else _move_for_harvest = true hf_harvest_spam = _harvest_spam -- set max value for spaming harvest key end if _move_for_harvest then hf_string = "true" else hf_string = "false" end printf("Harvest mode: move active="..hf_string.." / move ".._move_times.."x for ".._move_time.."ms. Spam harvest key "..hf_harvest_spam.." times.\n"); end if( data1 == _testKey ) then -- recalulate clickpoints depending from the actual windows position wx,wy,wwide,whigh = window.getRect(win); hf_x, hf_y = mouse.getPosition() printf("window position "..wx.."/"..wy.." window size "..wwide.."/"..whigh) printf(" cursor position at "..hf_x.."/"..hf_y.." or in AA windows "..hf_x-wx.."/"..hf_y-wy.."\n") local colorR, colorG, colorB = window.getPixel(win, hf_x-wx, hf_y-wy) printf("Pixel color at cursor position "..hf_x.."/"..hf_y.." R/G/B: "..colorR.."/"..colorG.."/"..colorB.."\n") local colorR, colorG, colorB = window.getPixel(win, _harvestNoticeX, _harvestNoticeY) printf("Pixel color at check pixel position ".._harvestNoticeX.."/".._harvestNoticeY.." R/G/B: "..colorR.."/"..colorG.."/"..colorB.."\n") -- mouse.setPosition(_harvestNoticeX, _harvestNoticeY ); end end end function Harvest() -- if time.diff(time.getNow(), hf_lastActionTime) < (5.5 + hf_rnd_add_harvest/100) then -- harvest cooldown if time.diff(time.getNow(), hf_lastActionTime) < (0.1 + hf_rnd_add_harvest/100) then -- we spam the harvest key return false end keyboard.virtualPress(win, _harvestKey, false); -- keyboard.virtualRelease(win, _harvestKey); hf_lastActionTime = time.getNow() hf_rnd_add_harvest = math.random(_rnd_add_harvest) hf_harvest_count = hf_harvest_count + 1 printf("\rWe spam harvest key "..keyboard.getKeyName(_harvestKey)..": "..hf_harvest_count.."/"..hf_harvest_spam.." "..hf_move_count.."/".._move_times); end function HarvestMoveSpot() -- check harvest sign (pixel color) -- dont move if still something to harvest if IsHarvestPixel() and _checkHarvestPixel == true then -- use pixel color check? printf("\nstill something there\n") return false end if _checkHarvestPixel == false and ( hf_harvest_count < _harvest_spam or _move_for_harvest == false ) then return false end hf_harvest_count = 0 -- reset press harvest key counter -- check if to stop moving if hf_move_count == _move_times then hf_move_count = 0 printf("Press "..keyboard.getKeyName(_pauseKey).." to restart harvesting or "..keyboard.getKeyName(_toggleKey).." to switch to plant mode.\n"); running = false return false end hf_move_count = hf_move_count + 1 printf("\nMove forward "..hf_move_count.."/".._move_times.." for ".._move_time.." ms.\n") keyboard.virtualPress(win, _forwardKey); system.rest(_move_time); -- running forward for x ms keyboard.virtualRelease(win, _forwardKey); return true end function initPlanting() hf_column = 1 -- start at spot 1/1 after loading new set hf_row = 1 lastxPosition = _start_x -- set x back to begin of row hf_plantPauseTimer = _plantPauseTimer + math.random(20) end function Planting() if time.diff(time.getNow(), hf_lastActionTime) < ( _plantCooldown + hf_rnd_add_plant/100 ) then -- planting cooldown + some more rest while keypressing/mouse set return false end local hf_mouseX, hf_mouseY if _rnd_add_x > 0 then hf_rnd_add_x = math.random(_rnd_add_x) else hf_rnd_add_x = 0 end -- add rnd to next x value if _rnd_add_y > 0 then hf_rnd_add_y = math.random(_rnd_add_y) else hf_rnd_add_y = 0 end -- add rnd to next y value -- calculate mouse position for plant spot -- hf_mouseX = _start_x + (hf_column-1) * _dist_x + hf_rnd_add_x if hf_column == 1 then hf_mouseX = lastxPosition + hf_rnd_add_x -- first column always nearly same position else hf_mouseX = lastxPosition + _dist_x + hf_rnd_add_x -- other columns with more distance if rows come closer end lastxPosition = hf_mouseX -- remember last x position hf_mouseY = _start_y + (hf_row-1) * _dist_y + hf_rnd_add_y -- recalulate clickpoints depending from the actual windows size wx,wy,wwide,whigh = window.getRect(win); mouse.setPosition(wx + hf_mouseX, wy + hf_mouseY ); printf("set position\n") system.rest(200); -- mouse.setVirtualPosition(wx + hf_mouseX, wy + hf_mouseY ); -- don't work -- setVirtualPosition seems not to change the mouse position in the AA windows independent if with or without focus -- to release unsuccessfull plant or to harvest spot we need max 2x right mouse button mouse.virtualPress(win, key.VK_RMOUSE, false); printf("release point and wait little\n") system.rest(100); mouse.virtualPress(win, key.VK_RMOUSE, false); printf("release point and wait little\n") system.rest(100); -- harvest via right mouse button in endless mode if activeMode == PLANTENDLESS_MODE then mouse.virtualPress(win, key.VK_RMOUSE, false); printf("Harvest Plant point and wait\n") system.rest(5000); -- harvest spot first end printf("Plant point: %2d/%d at %4d/%d Dist x/y: %d/%d\n", hf_column, hf_row, hf_mouseX, hf_mouseY, _dist_x, _dist_y); system.rest(400); keyboard.virtualPress(win, _plantKey, false); system.rest(900); -- needs min 800ms diff between choosing seed and press mouse to plant -- mouse.virtualPress(win, key.VK_LMOUSE, false); -- don't work, some key presses are missed mouse.virtualPress(win, key.VK_LMOUSE); system.rest(200); -- needs min 200ms diff to recognize mouse press mouse.virtualRelease(win, key.VK_LMOUSE); hf_lastActionTime = time.getNow() -- remember last planting time for cooldown calculation hf_rnd_add_plant = math.random(_rnd_add_plant) return true end function PlantingSetNextSpot() -- set next planting spot: column / row hf_column = hf_column + 1 if hf_column > _columns then -- next row hf_column = 1 hf_row = hf_row + 1 lastxPosition = _start_x -- set x back to begin of row -- shift next row half x value to right ? if _usePlantOffset and hf_row/2-math.floor(hf_row/2) == 0 then -- even number row? lastxPosition = lastxPosition - _dist_x / 2 -- shift line x/2 to left end -- tune x/y value depending from distance/row -- _dist_x = _dist_x + _tuningx * (hf_row-1) -- _dist_x = _dist_x + _tuningx if _tuningx ~= 0 then _dist_x = _dist_x + ( _tuningx ^ ( hf_row + 1 ) ) -- using exponential value for closer rows else _dist_x = _dist_x + _tuningx end -- _dist_y = _dist_y + _tuningy * (hf_row-1) _dist_y = _dist_y + _tuningy -- reduce columns for closer rows _columns = _columns - _tuneColumn if hf_row > _rows then hf_column = 1 hf_row = 1 lastxPosition = _start_x -- set x back to begin of row if activeMode == PLANTENDLESS_MODE then subMode = "pause" printf("Short break before next planting round: "..hf_plantPauseTimer.." seconds.\n"); else running = false print("Planting finished") printf("Press "..keyboard.getKeyName(_pauseKey).." to start planting or "..keyboard.getKeyName(_toggleKey).." to switch to harvest mode.\n"); end end end end function AntiAfk() if time.diff(time.getNow(), hf_lastActionTime) < hf_afkTimer then -- check afk timer return false end keyboard.virtualPress(win, _antiafkKey, false); hf_lastActionTime = time.getNow() -- remember time we do something hf_afkTimer = rnd_value(_afkTimerMin, _afkTimerMax) -- set new random value for afk timer printf("We Press "..keyboard.getKeyName(_antiafkKey).." for anti AFK. Next action in "..hf_afkTimer.." seconds.\n"); return true end function SwitchPlantingSet() activeSet = activeSet + 1 if activeSet > #paraset then activeSet = 1 end _setname = paraset[activeSet]._setname _start_x = paraset[activeSet]._start_x _start_y = paraset[activeSet]._start_y _dist_x = paraset[activeSet]._dist_x _dist_y = paraset[activeSet]._dist_y _columns = paraset[activeSet]._columns _tuneColumn = paraset[activeSet]._tuneColumn _rows = paraset[activeSet]._rows _rnd_add_x = paraset[activeSet]._rnd_add_x _rnd_add_y = paraset[activeSet]._rnd_add_y _tuningx = paraset[activeSet]._tuningx _tuningy = paraset[activeSet]._tuningy _plantPauseTimer = paraset[activeSet]._plantPauseTimer _usePlantOffset = paraset[activeSet]._usePlantOffset initPlanting() end function PrintActivePlantingValues() printf("Active planting set: ".._setname.."\n"); printf(_rows.."x".._columns.." columns / dist x/y:".._dist_x.."(+rnd ".._rnd_add_x..")/".._dist_y.."(+rnd ".._rnd_add_y..") tune x/y:".._tuningx.."/".._tuningy.." start at ".._start_x.."/".._start_y.."\n"); end function SpamMessage() if time.diff(time.getNow(), hf_lastActionTime) < hf_spamMsgTimer then -- check spam message timer return false end keyboard.virtualPress(win, key.VK_ENTER, false); sendStringToKeyboard(spamMsg[activeSpamMsg]) keyboard.virtualPress(win, key.VK_ENTER, false); hf_lastActionTime = time.getNow() -- remember time we do something hf_spamMsgTimer = rnd_value(_spamTimerMin, _spamTimerMax) -- set new random value for spam timer printf("We send spam message. Next action in "..hf_spamMsgTimer.." seconds.\n"); activeSpamMsg = activeSpamMsg + 1 if activeSpamMsg > #spamMsg then activeSpamMsg = 1 end return true end function rnd_value(_min, _max) if (_max - _min) == 0 then -- no range between min & max return _min -- we return min end local value value = _min + math.random(_max - _min) -- set new random add for afk timer return value end function sendStringToKeyboard(_string) if useVirtualType == true then -- Version 1.9.21 or higher sendStringToKeyboardNew(_string) else -- Version 1.9.20 and below sendStringToKeyboardOld(_string) end end function sendStringToKeyboardNew(_string) printf("new version\n") keyboard.virtualType(win, _string) end function sendStringToKeyboardOld(_string) printf("old version\n") for i = 1, string.len(_string), 1 do local char = string.sub(_string, i, i); if string.match(char, "%u") then keyboard.hold(key.VK_SHIFT) end if string.upper(char) == "A" then keyboard.virtualPress(win, key.VK_A, false); elseif string.upper(char) == "B" then keyboard.virtualPress(win, key.VK_B, false); elseif string.upper(char) == "C" then keyboard.virtualPress(win, key.VK_C, false); elseif string.upper(char) == "D" then keyboard.virtualPress(win, key.VK_D, false); elseif string.upper(char) == "E" then keyboard.virtualPress(win, key.VK_E, false); elseif string.upper(char) == "F" then keyboard.virtualPress(win, key.VK_F, false); elseif string.upper(char) == "G" then keyboard.virtualPress(win, key.VK_G, false); elseif string.upper(char) == "H" then keyboard.virtualPress(win, key.VK_H, false); elseif string.upper(char) == "I" then keyboard.virtualPress(win, key.VK_I, false); elseif string.upper(char) == "J" then keyboard.virtualPress(win, key.VK_J, false); elseif string.upper(char) == "K" then keyboard.virtualPress(win, key.VK_K, false); elseif string.upper(char) == "L" then keyboard.virtualPress(win, key.VK_L, false); elseif string.upper(char) == "M" then keyboard.virtualPress(win, key.VK_M, false); elseif string.upper(char) == "N" then keyboard.virtualPress(win, key.VK_N, false); elseif string.upper(char) == "O" then keyboard.virtualPress(win, key.VK_O, false); elseif string.upper(char) == "P" then keyboard.virtualPress(win, key.VK_P, false); elseif string.upper(char) == "Q" then keyboard.virtualPress(win, key.VK_Q, false); elseif string.upper(char) == "R" then keyboard.virtualPress(win, key.VK_R, false); elseif string.upper(char) == "S" then keyboard.virtualPress(win, key.VK_S, false); elseif string.upper(char) == "T" then keyboard.virtualPress(win, key.VK_T, false); elseif string.upper(char) == "U" then keyboard.virtualPress(win, key.VK_U, false); elseif string.upper(char) == "V" then keyboard.virtualPress(win, key.VK_V, false); elseif string.upper(char) == "W" then keyboard.virtualPress(win, key.VK_W, false); elseif string.upper(char) == "X" then keyboard.virtualPress(win, key.VK_X, false); elseif string.upper(char) == "Y" then keyboard.virtualPress(win, key.VK_Y, false); elseif string.upper(char) == "Z" then keyboard.virtualPress(win, key.VK_Z, false); elseif char == "1" then keyboard.virtualPress(win, key.VK_1, false); elseif char == "2" then keyboard.virtualPress(win, key.VK_2, false); elseif char == "3" then keyboard.virtualPress(win, key.VK_3, false); elseif char == "4" then keyboard.virtualPress(win, key.VK_4, false); elseif char == "5" then keyboard.virtualPress(win, key.VK_5, false); elseif char == "6" then keyboard.virtualPress(win, key.VK_6, false); elseif char == "7" then keyboard.virtualPress(win, key.VK_7, false); elseif char == "8" then keyboard.virtualPress(win, key.VK_8, false); elseif char == "9" then keyboard.virtualPress(win, key.VK_9, false); elseif char == "0" then keyboard.virtualPress(win, key.VK_0, false); elseif char == " " then keyboard.virtualPress(win, key.VK_SPACE, false); elseif char == "+" then keyboard.virtualPress(win, key.VK_ADD, false); elseif char == "-" then keyboard.virtualPress(win, key.VK_SUBTRACT, false); elseif char == "*" then keyboard.virtualPress(win, key.VK_MULTIPLY, false); elseif char == "," then keyboard.virtualPress(win, key.VK_DECIMAL, false); elseif char == "/" then -- keyboard.hold(key.VK_SHIFT) -- keyboard.virtualPress(win, key.VK_7, false); keyboard.virtualPress(win, key.VK_DIVIDE, false); -- keyboard.release(key.VK_SHIFT) end if string.match(char, "%u") then keyboard.release(key.VK_SHIFT) end end end function ModeToString(_activeMode) if _activeMode == HARVEST_MODE then return "harvest"; end if _activeMode == PLANT_MODE then return "plant"; end if _activeMode == SPAM_MODE then return "spam message"; end if _activeMode == CLAIMSPOT_MODE then return "claim spot"; end if _activeMode == PLANTENDLESS_MODE then return "endless plant/harvest"; end return false end function CheckRuntime() if time.diff(time.getNow(), scriptStartTime) < _scriptMaxRuntime*60 then -- check runtime return false end error("Script max runtime reached after ".._scriptMaxRuntime.." minutes.\n", 0); end function IsHarvestPixel() if 1 == 1 then return false -- function still in develpoment end system.rest(400) -- give a litte time to show up harvest notice local colorR, colorG, colorB = window.getPixel(win, _harvestNoticeX, _harvestNoticeY) -- printf(colorR.."/"..colorG.."/"..colorB.."/n") local hf_string = colorR..colorG..colorB for i,v in pairs(harvestColors) do printf("\nv: "..v.." \n") printf("hf_string: "..hf_string.."\n") if v == hf_string then printf("\nTreffer, wir bleiben: "..hf_string.."\n") return true end end printf("\nWir können weiter gehen. Farbe des Pixels: "..hf_string.."\n") return false end function ClaimSpot() if time.diff(time.getNow(), hf_lastActionTime) < 0.1 then -- check spam message timer return false end -- recalulate clickpoints depending from the actual windows position wx,wy,wwide,whigh = window.getRect(win); mouse.setPosition(wx + _spotMouseX, wy + _spotMouseY ); system.rest(200); mouse.virtualPress(win, key.VK_RMOUSE, false); -- release not working click from before system.rest(200); keyboard.virtualPress(win, _useDesignKey, false); mouse.virtualPress(win, key.VK_LMOUSE); -- claim spot system.rest(200); -- needs min 200ms diff to recognize mouse press mouse.virtualRelease(win, key.VK_LMOUSE); system.rest(200); -- needs min 200ms diff to recognize mouse press mouse.virtualPress(win, key.VK_LMOUSE); -- claim spot system.rest(200); -- needs min 200ms diff to recognize mouse press mouse.virtualRelease(win, key.VK_LMOUSE); system.rest(200); -- needs min 200ms diff to recognize mouse press -- press confirmation button mouse.setPosition(wx + _confirmButtonX, wy + _confirmButtonY ); system.rest(200); -- mouse.virtualPress(win, key.VK_LMOUSE); -- claim spot -- system.rest(200); -- needs min 200ms diff to recognize mouse press -- mouse.virtualRelease(win, key.VK_LMOUSE); hf_lastActionTime = time.getNow() -- remember time we do something end function checkPlantingPauseFinished() if time.diff(time.getNow(), hf_lastActionTime) < hf_plantPauseTimer then -- harvest pause between next plant round return false end hf_plantPauseTimer = _plantPauseTimer + math.random(20) printf("Pause finised. we start with next plant round.\n"); subMode = "" -- clear submode return true end