|
Post by illunic on Oct 2, 2020 9:53:27 GMT
Hello I have been working on a script for a short while and have been running into a fair amount of issues because I have literally no background in programming. I was wondering if there was any plan to create a discord server for Ankulua so newbies like myself can ask stupid questions without flooding a forum with threads. Searching the forums got me nothing and was curious if there were any plans for a server in the future, I dont think they cost anything.
That aside my Ankulua questions:
I want to use FindAll() to find several identical instances of a pattern and then be able to choose one of the instances to click. I have no trouble with the find all but I am not sure how to go about randomly choosing one of the found instances.
also how do you a loop in this thing, I was trying while true / return false stuff but using multiple ones seems to mess with it. Is there a loop / break i am not seeing here or do i just need to return true after using one within another
lastly when certain conditions rent met I want the script to jump back up to a previous line, is there a method of doing that? I tried using goto but i cant see to figure it out.
|
|
|
Post by AnkuLua on Oct 2, 2020 14:06:51 GMT
The major problem of discord is hard to keep on the same thread. It's even harder to find the questions and answers.
To click on random one of findAll(), try this
t = findAll("target.png") click(t[math.random(#t)])
Not sure what you want about loop.
About jump back to a previous one when some condition, it would be easier to copy the line after if the condition true.
It would be easier if you could provide some example.
|
|
|
Post by illunic on Oct 2, 2020 16:59:08 GMT
Okay so I am making an attempt at making a combat script for the game EVE Echoes. The game has things called anomalies that you can fight a set number of NPC enemies. Once you clear it you need to go to a new one. This was where I was interested in the 'goto' stuff to use it to jump back up to the selection and fight. Something like this:
A Select and fly to anomaly B Fight the NPCs C if no more NPCs are detected goto C
Hopefully that makes a bit more sense. I was trying to use it to have the bot re-execute a certain section of code without having to loop all the way through the script to do it again.
Is there a way to set a global wait() between commands? So I don't have to keep adding wait(#) inbetween actions?
|
|
|
Post by AnkuLua on Oct 2, 2020 22:28:50 GMT
First, what you said is not clear still. The following is possible a dead loop C if no more NPCs are detected goto C -- set a global wait() between commands How about a function with wait()? And for Eve Echo, there is already a popular one. ankulua.boards.net/thread/1793/eve-echoes-mining-botYou may ask the script author to meet your wishes.
|
|
|
Post by illunic on Oct 5, 2020 23:54:18 GMT
Okay more question attempts this one is going to be about tables.
Is there a way to print a whole table on a single line.
num1 = {"2","1","3","5","4"}
dialogInit() addTextView("Number Sequence: "..num1) dialogShowFullScreen("test") Trying that just makes it throw an error. I am trying to get a dialog that looks like: Number Sequence: 2 1 3 5 4 Im not sure if its possible, I tried a few things to no avail and checking to see is more knowledgeable people know if its possible or I'm just out of luck.
Second question is if I have a table that consists of a few pngs like: tstpng = {"1.png", "2.png", "3.png"}
and I do:
if exists(tstpng) then Does this work and if it does will it just need one of the pngs to be found to then or will it need to find all 3 of them?
EDIT: One more, is there a way to display text on the game screen? I want to have a successful loop counter on the screen while im still testing everything. I thought was toast but that just popped up for a few seconds then disappeared.
|
|
|
Post by AnkuLua on Oct 6, 2020 6:48:50 GMT
You can use following function to show table as you want function tableToString(tab) res = "" for i, t in pairs(tab) do res = res .. " " .. t end return res end
Then call it with addTextView("Number Sequence: ".. tableToString(num1)) You can't use exists() on table. Use for in pairs to perform actions on each table element. To display text on the game screen, use region highlight with text Region(100, 200, 100, 300):highlight("Hello") ankulua.boards.net/thread/6/objects-methods-introduction-sikuli-compatible#highlight
|
|
|
Post by illunic on Oct 6, 2020 7:28:54 GMT
Awesome, thank you for the help! Anyway to remove the background color for highlight?
|
|
|
Post by AnkuLua on Oct 6, 2020 13:38:48 GMT
Awesome, thank you for the help! Anyway to remove the background color for highlight? It's in the highlight description setHighlightTextStyle (bgColor, textColor, textSize)
|
|
|
Post by illunic on Oct 6, 2020 16:13:08 GMT
Cool, got it working. Last question for now is there something that checks if a png is not present? Something like notExists()? I have been using waitVanish() but its reliability seems to be questionable. The description of waitVanish seems to suggest its waiting for an object that is there to disappear so I am not sure if it works the same as checking if an object is not present. Just curious if waitVanish() is my only option or something else like exists that Im missing.
|
|
|
Post by AnkuLua on Oct 7, 2020 7:49:21 GMT
Cool, got it working. Last question for now is there something that checks if a png is not present? Something like notExists()? I have been using waitVanish() but its reliability seems to be questionable. The description of waitVanish seems to suggest its waiting for an object that is there to disappear so I am not sure if it works the same as checking if an object is not present. Just curious if waitVanish() is my only option or something else like exists that Im missing. if (not exists("target.png")) then -- do what you want when not existing end
|
|
|
Post by illunic on Oct 7, 2020 21:22:44 GMT
Does that work if you are searching a region? I'm trying if (tgtregion:not exists ("target.png") then
Its throwing me a syntax error, am I missing some () somewhere?
|
|
|
Post by Mercobots on Oct 7, 2020 22:42:12 GMT
Does that work if you are searching a region? I'm trying if (tgtregion:not exists ("target.png") then
Its throwing me a syntax error, am I missing some () somewhere?
Just giving a little hand! So the "NOT" is lua syntax and not ankulua API, like php uses "!" operator, in that order if you use "NOT" operator, you should use it before any ankulua obj and not mix it! if not exists() thenif not my_region:exists() thenif not my_region:existsClick() thenif not my_region:exists() and not my_region:existsClick()thenHope this help more than confuse you
|
|
|
Post by illunic on Oct 7, 2020 22:45:50 GMT
That clears it up, thanks a bunch! Ive got no past programming experience so I am just kinda playing it by ear. Forums have been greatly helpful in this venture
|
|
|
Post by illunic on Oct 11, 2020 15:47:05 GMT
So regarding a previous question about selecting a random findAll()
t = findAll("target.png") click(t[math.random(#t)]) I've run into issues with it not finding the 'target.png' and throwing an error. My question is if i instead fo a t = findAllNoExecptions("target.png") and it still does not find any of the target.png will it still generate something for (t) and will it make the click random throw an error? I am trying to prevent error messages from popping up. I thought about using an if then to check if t had what i need in it before trying to do a random selection. Something like
t = {} t = listToTable(findAllNoExceptions("target.png"))
if t != {} then click(t[math.random(#t)]) else stuff
would this work?
|
|
|
Post by Mercobots on Oct 11, 2020 22:30:41 GMT
So regarding a previous question about selecting a random findAll() t = findAll("target.png") click(t[math.random(#t)]) I've run into issues with it not finding the 'target.png' and throwing an error. My question is if i instead fo a t = findAllNoExecptions("target.png") and it still does not find any of the target.png will it still generate something for (t) and will it make the click random throw an error? I am trying to prevent error messages from popping up. I thought about using an if then to check if t had what i need in it before trying to do a random selection. Something like t = {} t = findAllNoExceptions("target.png")
if t != {} then click(t[math.random(#t)]) else stuff would this work? for your question yes findAllNoExecptions returns always a table of match or a empty table on failure what i sujest is the following t = {} t = findAllNoExceptions("target.png")
if #t > 0 then
click(t[math.random(1,#t)]) else stuff in lua to count all elements in an indexed table you use #your_table ! so when you use findAllNoExceptions and no math was found you get a table whit 0 elements
|
|