Здравствуйте, гость ( Вход | Регистрация )

 
Ответить в эту темуОткрыть новую тему
> Need script for findcolor
killerwhale123
сообщение 29.9.2023, 9:11
Сообщение #1


*

Registred
Сообщений: 8
Регистрация: 29.9.2023
Группа: Пользователи
Наличность: 0
Пользователь №: 20.617
Возраст: 25



Hello im trying to make a script to collect ores. The ore i want to collect spawns in different locations every 3 minutes. Im kinda new to find color command. Can someone make me a script for uopilot that finds the ore in my screen and right clicks it to collect it? The script i made doesnt find the ore and it keeps repeating the command but nothing happens. It feels like the script is scanning only the top left part of the screen and not the entire window. The ore is this: https://prnt.sc/FryMTWoOgd4v My script that doesnt work is this:

set workwindow 10354828
set #startX 1
set #startY 1
set #endX 1920
set #endY 1080

set #a findcolor (#startX #startY #endX #endY (1617573 )%arr workwindow)
if #a > 0
double_right %arr[1 1] %arr[1 2]
double_right %arr[1 1] %arr[1 2]
wait 10s

left 451, 477
wait 3min
end_if

Can someone make me a better script?
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
yodich
сообщение 30.9.2023, 16:46
Сообщение #2


***

Novice
Сообщений: 90
Регистрация: 24.8.2020
Группа: Пользователи
Наличность: 0
Пользователь №: 19.728
Возраст: 29



Код


--lua
function print ( ... ) return log ( ... ) end print ('clear')

local function fc (xstart, ystart, xend, yend, colors, count) -- x, y, xend, yend, colors, countColors
  local intCount = count or 2
  local counter = 0
  local intColors = colors or {}
  for i = 1, #intColors do
    local RC = findcolor (xstart, ystart, xend, yend, intColors[i], "%RCm", WindowWork)
    if RC then counter = counter + 1
      if counter >= intCount then x, y = RCm[1][1], RCm[1][2] return x, y end
    end
  end
end
  
function Work (nameWork, fullscreen)
  local fullscreen = fullscreen or false
  local workwin = findwindow (nameWork)
  if ( workwin ) then
    local WindowWork = workwindow (workwin[1][1], "child")
    if ( fullscreen == true ) or ( fullscreen == "fullscreen" ) then showwindow ( WindowWork, "maximize" ) end
    xth, yth, width, height, errorcode =  windowpos (WindowWork)
  else
    msg ("Error Window")
    end_script()
  end
return workwin
end

local WinGame = Work ("You Name Window")

local MyColors = {
      {
        "Ruda",
        2060642, 1665111, 1858385, 2454882, 1928028, 2653031, 1593670, 2518108, 1667422, 1734509
      }
      
      --[[
        {
        Here you can enter your own colors
        }
      ]]--
    }

while WinGame do
  
  for i = 1, #MyColors do
    local Ruda = fc (xth, yth, width, height, MyColors[i], 5, WindowWork)
    
    if Ruda then
      -- here's your code
      double_right (x, y) -- double right click
      wait (10000) -- 10 sec
      break
    end
  end
  
  --- here's your code
  left (100, 100)
  wait (180000)
end

Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
killerwhale123
сообщение 30.9.2023, 20:37
Сообщение #3


*

Registred
Сообщений: 8
Регистрация: 29.9.2023
Группа: Пользователи
Наличность: 0
Пользователь №: 20.617
Возраст: 25



Okay thank you but im not very familiar with lua. Do i have to create modules and import them in uopilot or i can copy ur entire code and put it in the uopilot as it is? Also can you tell me what parts of the code i have to replace? I put it in uopilot as it is
I only replaced local WinGame = Work ("You Name Window") and { Here you can enter your own colors }. It doesnt show an error but also it doesnt do anything. Also do i have to run the game in fullscreen? I play in windowed mode not fullscreen Uopilot log window : https://prnt.sc/Q2W2C9t1-UPw
My code looks like this :

Код

--lua
function print ( ... ) return log ( ... ) end print ('clear')

local function fc (xstart, ystart, xend, yend, colors, count) -- x, y, xend, yend, colors, countColors
  local intCount = count or 2
  local counter = 0
  local intColors = colors or {}
  for i = 1, #intColors do
    local RC = findcolor (xstart, ystart, xend, yend, intColors[i], "%RCm", WindowWork)
    if RC then counter = counter + 1
      if counter >= intCount then x, y = RCm[1][1], RCm[1][2] return x, y end
    end
  end
end

function Work (nameWork, fullscreen)
  local fullscreen = fullscreen or false
  local workwin = findwindow (nameWork)
  if ( workwin ) then
    local WindowWork = workwindow (workwin[1][1], "child")
    if ( fullscreen == true ) or ( fullscreen == "fullscreen" ) then showwindow ( WindowWork, "maximize" ) end
    xth, yth, width, height, errorcode =  windowpos (WindowWork)
  else
    msg ("Error Window")
    end_script()
  end
return workwin
end

local WinGame = Work ("Talisman Online | All Stars (NH) | ver.5956")

local MyColors = {
      {
        "Ruda",
        2976607, 2606500, 2470821, 1343588
      }

      --[[
        {
        2976607, 2606500, 2470821, 1343588
        }
      ]]--
    }

while WinGame do

  for i = 1, #MyColors do
    local Ruda = fc (xth, yth, width, height, MyColors[i], 5, WindowWork)

    if Ruda then
      -- here's your code
      double_right (x, y) -- double right click
      wait (10000) -- 10 sec
      break
    end
  end

  --- here's your code
  left (100, 100)
  wait (180000)
end
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
yodich
сообщение 30.9.2023, 21:39
Сообщение #4


***

Novice
Сообщений: 90
Регистрация: 24.8.2020
Группа: Пользователи
Наличность: 0
Пользователь №: 19.728
Возраст: 29



just paste the code into uopilot and change it where it is marked. I'll see where and what the error is
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
killerwhale123
сообщение 30.9.2023, 22:29
Сообщение #5


*

Registred
Сообщений: 8
Регистрация: 29.9.2023
Группа: Пользователи
Наличность: 0
Пользователь №: 20.617
Возраст: 25



i dont know where to change it
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
Madeus
сообщение 1.10.2023, 3:25
Сообщение #6


****

Apprentice
Сообщений: 283
Регистрация: 19.11.2019
Группа: Пользователи
Наличность: 8477
Пользователь №: 19.451
Возраст: 32



Change local Ruda = fc (xth, yth, width, height, MyColors[i], 5, WindowWork)
to local Ruda = fc (xth, yth, width, height, MyColors[i], 5, WinGame)
and you need to enter the coordinates: xth, yth, width, height
Пользователь в онлайне!Delete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
killerwhale123
сообщение 1.10.2023, 7:59
Сообщение #7


*

Registred
Сообщений: 8
Регистрация: 29.9.2023
Группа: Пользователи
Наличность: 0
Пользователь №: 20.617
Возраст: 25



i ran it but it doesn't right click the object, i think u made it too complicated for something simple. I need the script to scan my screen and find the object and right click it. The object changes locations every 3minutes
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
nykep
сообщение 1.10.2023, 10:52
Сообщение #8


****

Apprentice
Сообщений: 233
Регистрация: 1.9.2012
Группа: Пользователи
Наличность: 1213
Пользователь №: 15.246
Возраст: 25



could you upload screenshot on another hosting? i cant open it
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
killerwhale123
сообщение 1.10.2023, 20:18
Сообщение #9


*

Registred
Сообщений: 8
Регистрация: 29.9.2023
Группа: Пользователи
Наличность: 0
Пользователь №: 20.617
Возраст: 25



https://imgur.com/frlsaYq . Sometimes on the log window it says :
Failed to create image.
20:25:45 1 (autosaved_1.txt, 0): Failed to select a picture.
20:25:45 1 (autosaved_1.txt, 0): Failed to create an image from memory.
20:25:45 1 (autosaved_1.txt, 0): Did not close.
20:25:45 1 (autosaved_1.txt, 0): Did not open

Цитата(killerwhale123 @ 1.10.2023, 20:17) *

https://imgur.com/frlsaYq . Sometimes on the log window it says :
Failed to create image.
20:25:45 1 (autosaved_1.txt, 0): Failed to select a picture.
20:25:45 1 (autosaved_1.txt, 0): Failed to create an image from memory.
20:25:45 1 (autosaved_1.txt, 0): Did not close.
20:25:45 1 (autosaved_1.txt, 0): Did not open


Could you make a simpler script?
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
nykep
сообщение 1.10.2023, 21:55
Сообщение #10


****

Apprentice
Сообщений: 233
Регистрация: 1.9.2012
Группа: Пользователи
Наличность: 1213
Пользователь №: 15.246
Возраст: 25



Цитата(killerwhale123 @ 1.10.2023, 20:18) *

screenshot of game, not a uopilot
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
killerwhale123
сообщение 2.10.2023, 0:13
Сообщение #11


*

Registred
Сообщений: 8
Регистрация: 29.9.2023
Группа: Пользователи
Наличность: 0
Пользователь №: 20.617
Возраст: 25



https://imgur.com/a/qhcx3Tp This is the ore i want to right click but it changes location every 3minutes
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
nykep
сообщение 2.10.2023, 0:47
Сообщение #12


****

Apprentice
Сообщений: 233
Регистрация: 1.9.2012
Группа: Пользователи
Наличность: 1213
Пользователь №: 15.246
Возраст: 25



your script is almost fine. Problem is in type of search "workwindow" and color for search
Код

set workwindow 10354828
set #startX 1
set #startY 1
set #endX 1920
set #endY 1080
while 1 = 1
    set #a findcolor (#startX #startY #endX #endY (1146478-2188890) %arr 2 1 0)  // choose color range or deviation of color from 0 to 100 (0 in this example)
    if #a > 0
        double_right %arr[1 1] %arr[1 2]
        double_right %arr[1 1] %arr[1 2]
        wait 10s
        left 451, 477
        wait 3min
    end_if
end_while

this script will work only in active window. What is wrong with workwindow i dont know. This is WOW, so colors can change significantly, depends on camera position and illumination.
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
killerwhale123
сообщение 2.10.2023, 1:17
Сообщение #13


*

Registred
Сообщений: 8
Регистрация: 29.9.2023
Группа: Пользователи
Наличность: 0
Пользователь №: 20.617
Возраст: 25



Yeah my initial script worked but only sometimes. I will try your new one and see
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
killerwhale123
сообщение 2.10.2023, 21:08
Сообщение #14


*

Registred
Сообщений: 8
Регистрация: 29.9.2023
Группа: Пользователи
Наличность: 0
Пользователь №: 20.617
Возраст: 25



Your script works @nykep thanks
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения

Ответить в эту темуОткрыть новую тему
2 чел. читают эту тему (гостей: 2, скрытых пользователей: 0)
Пользователей: 0

 

- Текстовая версия | Версия для КПК Сейчас: 27.4.2024, 18:30
Designed by Nickostyle