|
|
|
Ускорить/Оптимизировать/сократить код |
|
|
kyja |
17.1.2021, 16:57
|
Novice
Сообщений: 85
Регистрация: 29.10.2016 Группа: Пользователи Наличность: 0
Пользователь №: 18.164
|
Подскажите пожалуйста как можно более правильно оформить такое количество if (в реальности их ровно в два раза больще) это условно долго даже для lua Разница только в количестве пикселей для clickoffsetx логика число 13+13, 26+13 39+13 и тд. Координата проверки всегда одна script
Код if color(959, 495 ) == 13460991 then --тянем стрелку вправо clickoffsetx (13 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 10040269 then --тянем стрелку вправо clickoffsetx (26 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 10027213 then --тянем стрелку вправо clickoffsetx (39 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 6566809 then --тянем стрелку вправо clickoffsetx (52 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 6553753 then --тянем стрелку вправо clickoffsetx (65 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 3342436 then --тянем стрелку вправо clickoffsetx (78 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13435135 then --тянем стрелку вправо clickoffsetx (91 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13448191 then --тянем стрелку вправо clickoffsetx (104 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 10027161 then --тянем стрелку вправо clickoffsetx (117 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 6566756 then --тянем стрелку вправо clickoffsetx (130 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 6553700 then --тянем стрелку вправо clickoffsetx (143 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 3342387 then --тянем стрелку вправо clickoffsetx (156 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 10027108 then --тянем стрелку вправо clickoffsetx (169 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 10040164 then --тянем стрелку вправо clickoffsetx (182 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13460889 then --тянем стрелку вправо clickoffsetx (195 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16711833 then --тянем стрелку вправо clickoffsetx (208 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16724889 then --тянем стрелку вправо clickoffsetx (221 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16751053 then --тянем стрелку вправо clickoffsetx (234 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16737741 then --тянем стрелку вправо clickoffsetx (247 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16724941 then --тянем стрелку вправо clickoffsetx (260 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16711885 then --тянем стрелку вправо clickoffsetx (273 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13448089 then --тянем стрелку вправо clickoffsetx (286 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13435033 then --тянем стрелку вправо clickoffsetx (299 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13434980 then --тянем стрелку вправо clickoffsetx (312 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13448036 then --тянем стрелку вправо clickoffsetx (325 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 6553651 then --тянем стрелку вправо clickoffsetx (338 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 10027059 then --тянем стрелку вправо clickoffsetx (351 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16711731 then --тянем стрелку вправо clickoffsetx (364 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16724836 then --тянем стрелку вправо clickoffsetx (377 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16751001 then --тянем стрелку вправо clickoffsetx (390 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16764109 then --тянем стрелку вправо clickoffsetx (403 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13474201 then --тянем стрелку вправо clickoffsetx (416 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 10052964 then --тянем стрелку вправо clickoffsetx (429 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13460836 then --тянем стрелку вправо clickoffsetx (442 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 6553600 then --тянем стрелку вправо clickoffsetx (455 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 3342336 then --тянем стрелку вправо clickoffsetx (468 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 6566707 then --тянем стрелку вправо clickoffsetx (481 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13460736 then --тянем стрелку вправо clickoffsetx (494 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13447936 then --тянем стрелку вправо clickoffsetx (507 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 10040064 then --тянем стрелку вправо clickoffsetx (520 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 16764004 then --тянем стрелку вправо clickoffsetx (533 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 10079332 then --тянем стрелку вправо clickoffsetx (546 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 52275 then --тянем стрелку вправо clickoffsetx (559 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 52224 then --тянем стрелку вправо clickoffsetx (572 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 3394611 then --тянем стрелку вправо clickoffsetx (585 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 6605924 then --тянем стрелку вправо clickoffsetx (598 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end if color(959, 495 ) == 13500365 then --тянем стрелку вправо clickoffsetx (611 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end
Сообщение отредактировал Fors1k - 18.1.2021, 14:25
|
|
|
|
kyja |
17.1.2021, 17:46
|
Novice
Сообщений: 85
Регистрация: 29.10.2016 Группа: Пользователи Наличность: 0
Пользователь №: 18.164
|
Как обычно я криво описал смысл извиняюсь, хендл указан Код local handle = findwindow ("World") if handle then -- если окно найдено workwindow (handle[1][1]) -- сделать его рабочим окном end while color(959, 495) ~= 16715776 and color(867, 447) ~= 2048 do --тянем мышку пока не ок цвет стрелки или финиш
if color(959, 495 ) == 13460991 then --тянем стрелку вправо clickoffsetx (13 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end end В оригинале там идет еще ~ 100 проверок на цвет, и разное действие от цвета. Но цвет который ищется 100% будет в списке ifов то есть может быть более правильно было бы что то вроде code
Код while color(959, 495) ~= 16715776 and color(867, 447) ~= 2048 do --тянем мышку пока не ок цвет стрелки или финиш
local a = color (959, 495) --определяем цвет --в зависимости от цвета который получили например 13460991 переходим к нужному действию
if color(959, 495 ) == 13460991 then --тянем стрелку вправо clickoffsetx (13 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end
if color(959, 495 ) == 10040269 then --тянем стрелку вправо clickoffsetx (26 + math.random (2)) local x, y = mouse_pos () move_smooth (x, y) local x, y = mouse_pos () end
end Как правильно написать такой вариант? Сообщение отредактировал Fors1k - 18.1.2021, 14:26
|
|
|
|
cirus |
17.1.2021, 18:04
|
Elder
Сообщений: 3.480
Регистрация: 18.8.2014 Группа: Пользователи Наличность: 26706
Пользователь №: 16.971
Возраст: 29
|
Цитата хендл указан Имеется ввиду хендл в самой функции color. Код color(959, 495, handle[1][1]) Но, оно коряво реализовано, поэтому надо длл использовать https://forum.uokit.com/index.php?showtopic=69910. Это потом можно изменить, пока с циклами разберитесь. Код --lua log 'clear' log 'mode compact'
local all_color = {13460991, 10040269, 52224, 52275 } -- массив с цветами local action = {'Действие1', 'Действие2', 'Действие3', 'Действие4'} -- действия
-- т. е. для цвета 13460991 будет выполняться Действие1 -- для цвета 10040269 будет выполняться Действие2 -- и т. д.
local _color = color(959, 495) -- узнали цвет for i=1, #all_color do -- цикл, сравнить полученный цвет с цветами в массиве log ('Проверка цвета: ' .. tostring(all_color[i])) if _color == all_color[i] then -- если цвет совпал -- нужные действия log (tostring(all_color[i]) .. ' '..action[i]) end end
|
|
|
|
cirus |
17.1.2021, 21:12
|
Elder
Сообщений: 3.480
Регистрация: 18.8.2014 Группа: Пользователи Наличность: 26706
Пользователь №: 16.971
Возраст: 29
|
Цитата local action тоже ничего action это просто имя переменной, в данном случае массива, можете написать любое другое. Цитата Можно пожалуйста пример как сделать допустим совпал Действие1 переместить мышку в координаты например 333, 333 или совпал Действие2 переместить в координаты 555, 555 Код --lua log 'clear' log 'mode compact'
local all_color = {1114112, 0 } -- массив с цветами local coord = {{333, 333}, {555, 555}} -- координаты
local _color = color(959, 495) -- узнали цвет for i=1, #all_color do -- цикл, сравнить полученный цвет с цветами в массиве log ('Проверка цвета: ' .. tostring(all_color[i])) if _color == all_color[i] then -- если цвет совпал -- нужные действия move (coord[i][1], coord[i][2]) end end
|
|
|
|
|
|
2 чел. читают эту тему (гостей: 2, скрытых пользователей: 0)
Пользователей: 0
|
|