← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #666773]: How to get on the road as a newcomer to Java programming

 

Question #666773 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/666773

Alexander Schone posted a new comment:
Ah that explains my struggles so far.. I thought I was just a very slow
learner but apparently I chose a tough entry :)

Thank you for the clarifications! with the help of a friend I was able
to get to this stage:

import java.util.ArrayList;
import java.util.List;

import org.sikuli.basics.Debug;
import org.sikuli.script.*;


public class Script {
	
	public static void main(String[] args) throws FindFailed {
//		Debug.setDebugLevel(3);
		Screen s = new Screen();
		
		// Declare region
		Region totalRollArea = new Region(20, 20, 100, 50);
		
		List<Object> imageList = new ArrayList();
		imageList.add("number1.png");
		imageList.add("number2.png");
		List<Match> numbers = totalRollArea.findAnyList(imageList);
		int indexValue = 0;
		
		for (Match match : numbers) {
			indexValue = match.getIndex();
				if (indexValue >= 1) {
			System.out.println("true");

This code works to find images "number1.png" and "number2.png" and
print "true". For test I took windows icon and folder icon as number1
and number2 and used  screen instead of region which of course led to
long execution time.

The purpose of my script is to automate the abilities section of DnD based games like Icewind Dale (in my case) or Baldurs Gate. The game will roll a value which I want to compare to an internally set value (roll value should be >= 86). This roll value is composed of two numbers (ten digits and one digits) which I want to get from screen and then if value isnt sufficient press the "reroll" button and start the for loop again. Now the question: Do you think this part of the script can be executed quick enough to use lets say not more than 0.2 seconds to determine if the roll value goal is met (the area to check will be defined by a very small region so the actual find area will be only about 200 pixels)?
And do you see any room for improvement or more simplicity or better readability?

I hope I phrased this in a way that it makes sense.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.