|
Post by japierdole on Jan 8, 2017 19:04:24 GMT
I am using function waitClick How I can handle exception when image is not present? I want to know when image is not present, so I run another code.
|
|
|
Post by AnkuLua on Jan 9, 2017 0:09:27 GMT
Just use existsClick()
if (not existsClick("target.png")) then .... end
|
|
|
Post by japierdole on Jan 9, 2017 0:58:44 GMT
Just use existsClick() if (not existsClick("target.png")) then .... end Friend, I must use waitClick function, so I will know if code will find this image. For example in pseudocode: try waitClick("image.png") catch exception: -- image not found! Running another function! end
Some other code, that is running after image is found, or after exception is handled.
Is there any way to catch exceptions in ankulua?
|
|
|
Post by japierdole on Jan 9, 2017 1:00:09 GMT
Just use existsClick() if (not existsClick("target.png")) then .... end Can I run existsClick with timer, for example 5 seconds? existsClick("target.png",5) then ... end ? I am asking, because I can't find documentation that I can read.
|
|
|
Post by AnkuLua on Jan 9, 2017 1:11:05 GMT
|
|
|
Post by japierdole on Jan 9, 2017 1:21:45 GMT
Thank you friend. Is there also goto function? I want fast go to start of the program. I know that using goto is not a good practice, but it will save me time.
|
|
|
Post by AnkuLua on Jan 9, 2017 1:35:04 GMT
No. goto is not supported.
|
|
|
Post by vampiredbr9 on Jan 9, 2017 20:19:44 GMT
Ankulua, I think the poster of this thread actually has a point- I have code which is like this If exists("a.png") then Dragdrop("a.png", location) End However during the time taken to find if a exists, it disappears from screen leading to the script ending, and me being very cross at my code. Any advice? Edit: found out way to fix from Lua docs, posting link and example below to help other users
|
|
|
Post by vampiredbr9 on Jan 9, 2017 20:22:52 GMT
|
|
|
Post by vampiredbr9 on Jan 9, 2017 20:49:04 GMT
Function battle() Click("test.png") --Badly coded on purpose, no test.png on screen, so returns error End if not(pcall(battle)) then Toast("error occured- ignoring") --If an error occured during battle function end
|
|
|
Post by vampiredbr9 on Jan 9, 2017 20:54:07 GMT
Thank you friend. Is there also goto function? I want fast go to start of the program. I know that using goto is not a good practice, but it will save me time. Instead of goto, you could use functions??? Function display() Print("hi") End Display()
|
|
|
Post by japierdole on Jan 11, 2017 3:50:00 GMT
Function battle() Click("test.png") --Badly coded on purpose, no test.png on screen, so returns error End if not(pcall(battle)) then Toast("error occured- ignoring") --If an error occured during battle function end Wow great idea! I tried to use pcall, but I failed, and I thought that pcall not exists in akulua. What means: Toast("error occured- ignoring") What Toast displays?
|
|
|
Post by japierdole on Jan 11, 2017 3:50:37 GMT
Instead of goto, you could use functions??? Function display() Print("hi") End Display() Yes, good idea!
|
|
|
Post by vampiredbr9 on Jan 11, 2017 8:36:38 GMT
Function battle() Click("test.png") --Badly coded on purpose, no test.png on screen, so returns error End if not(pcall(battle)) then Toast("error occured- ignoring") --If an error occured during battle function end Wow great idea! I tried to use pcall, but I failed, and I thought that pcall not exists in akulua. What means: Toast("error occured- ignoring") What Toast displays? Pcall works in ankulua. It calls a function in protected mode (see example). Toast displays a notification to the user which displays for about 1 second
|
|