0

I'm created two variables that play different iimPlay functions. However, the code always execute the first if statement and ignore the 2nd statement.

Main.js

var ReturnCode = iimPlay("win.iim");  
var returncode2 = iimPlay("lose.iim"); //
if (ReturnCode = 1) {         *//when returncode =1 means complete execute*
iimPlay("reset.iim");
} 

if (returncode2 = 1 ) {
iimPlay("double.iim");
}

Win.iim

IMAGESEARCH POS=1 IMAGE=C:\win.png CONFIDENCE=65 

imagesearch will always execute no matter match or not

Lose.iim

IMAGESEARCH POS=1 IMAGE=C:\lose.png CONFIDENCE=65  

imagesearch will always execute no matter match or not

HTML tag

<div id="game-result" class="balance-change fail">
<span id="result-text">
LOST
</span> </div>

Problem : Whenever the iimPlay("win.iim") detects win or lose image, it still execute the first statement as fact that lose image should execute the second if statement.

Chozo Qhai
  • 283
  • 2
  • 10
  • 19

2 Answers2

1

Instead of using image search try with

TAG POS=1 TYPE=DIV ATTR=CLASS:image_you_are_looking_for CONTENT=EVENT:MOUSEOVER


TAG POS=1 TYPE=DIV  ATTR=CLASS:second_image_you_are_looking_for CONTENT=EVENT:MOUSEOVER

This way will return error code if it's not present.

And also this is the error.

if (returncode2 = 1 ) { }

You are setting value 1 into returncode2 not comparing it to 1. The correct is

if (returncode2 == 1 ) { }

Even better is:

if (returncode2 > 0 ) { }

Same for the other return code. Fix these and try again.

edinvnode
  • 3,497
  • 7
  • 30
  • 53
  • When I saw the win's image, it doesn't execute the both if statements, just jump to end of code line. I already used '==' and '>', but problem still remain. The win.iim does not show error, but lose.iim does. – Chozo Qhai Nov 07 '13 at 01:05
0

You need to be always careful with the EQUAL sign. In Javascript for comparasion you use == or ===. Your code does an attribution and will always be TRUE; that's why it is always executed. See this post for details about javascript equality.

Community
  • 1
  • 1
symbiotech
  • 1,277
  • 2
  • 17
  • 29