简体   繁体   English

在Java(NetBeans)中使用Sikuli插件时使用逻辑

[英]Using logic when working with Sikuli plug-in in Java (NetBeans)

first time post here! 第一次在这里发布!

So, I've have been trying to solve a (hopefully) rather simple issue that I'm having with my code. 因此,我一直在尝试解决我的代码遇到的(希望)一个非常简单的问题。

So, the scenario is that I'm making Sikuli search for two images, and execute different actions based on what it finds. 因此,这种情况是我要让Sikuli搜索两个图像,并根据发现的内容执行不同的操作。 A example of the code looks like following: 代码示例如下所示:

int x=2;
int y;

while(x>1){
    if(s.exists(victory.similar((float)0.70)) != null){ 
       y=1;
    }
    else if(s.exists(defeated.similar((float)0.70)) != null){
        y=2;
    }
    else{
    x++;}
}

But the problem that I am currently having, is the fact that this works only when it find the first alternative - being blind to the other one. 但是,我目前面临的问题是, 只有在找到第一个替代方案时才有效 -对另一个方案不了解。

This is happening over several scenarios within the code, of similar structure. 这是在代码中结构相似的几种情况下发生的。

A detail worth mentioning is probably also the fact that I am running this code with SwingWorker, yet still I do not really see any reason for this to influence the code due to the rest of this part of the script working well (as long it is not a part like the one mentioned above!). 值得一提的细节可能是我正在使用SwingWorker运行此代码的事实,但是由于脚本的这一部分的其余部分运行良好,我仍然没有真正看到任何影响代码的原因(只要不像上面提到的那样!)。

Thank You in advance for all the help! 预先感谢您提供的所有帮助!

另一种方法将被视为只是如果第一个( ),如果要检查两个if语句则必须删除别的词

Changing the script to 将脚本更改为

if(s.exists(victory.similar((float)0.70)) != null){ 
       y=1;
    }
    if(s.exists(defeated.similar((float)0.70)) != null){
        y=2;
    }
    else{
    x++;}

Did not solve the issue, for whatever reason the script stays blind... 不管出于什么原因,脚本都无法解决问题,因此无法解决问题...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM