The Wiki for Tale 4 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

User:Orrin/java1

From A Tale in the Desert
< User:Orrin
Revision as of 16:23, 21 January 2010 by Orrin (talk | contribs) (New page: /** * * Glass.java is used for making sheetglass. At the moment it's a bit * CC inefficient but should work with most if not all benches. If you * have a bench which drops more than 4 ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

/**

*
* Glass.java is used for making sheetglass. At the moment it's a bit
* CC inefficient but should work with most if not all benches. If you
* have a bench which drops more than 4 times as much as it gains from
* 2cc it will drop bellow 1600. Additionally if you have a bench
* which drops more than 200 or heats more than 150 it will break
* glass. You should modify the numWindows and numCols to match the
* number of benches and how many Columns of them you have before they
* wrap to the next line. Bench windows should be pinned and lined up
* exactly next to eachother without any space between (if you'd
* rather not do this by hand there's a method in Functions.java which
* will do it for you).
*
* EldradUlthran 2/29/08
*
* Modified by Orrin
*
*
**/

import java.awt.MouseInfo; import java.awt.Color;

public class Glass {

   private int numWindows = 2; //Total Number of windows open
   private int numCols = 1;	//Number of columns *OR* number of windows in each line. Same thing.

private int isGuilded = 1; //1 if guilded, 0 if private private int isLabelled = 1; //1 if it has a label, 0 if not private int ySystemOffset = 45; //Offset in px between the top of the screen and the top of the glazier bench dialogue private int YOffset = (16*(isGuilded+isLabelled)); //Total Y offset

   private int windowX = 288;	//Width of the Glazier bench window
   private int windowY = 416+YOffset;	//Height of the Glazier bench window
   private int xRefresh = 10;	//Unknown, where to click to refresh the window?
   private int yRefresh = 10;	//Unknown, where to click to refresh the window?
   private int xCC = 32;		//X position of 'Add CC' button. Remember to take position when making an item.
   private int yCC = 82+YOffset;	//Y position of 'Add CC' button. Remember to take position when making an item.
   private int xSheetglass = 32;	//X position of 'Make SG' button
   private int ySheetglass = 146+YOffset;	//Y position of 'Make SG' button
   private int xTemp = 10;		//X Position of Temperature bar, aim it at the very very start of the bar.
   private int yTemp = 318+YOffset;	//Y Position of Temperature bar, aim it at the middle of the bar
   private int tempWidth = 268;	//Width of the Temperature bar, fixed.
   private int xProject = 10;		//X Location of the window in which the current project time is displayed.
   private int yProject = 398+YOffset;		//y Location of the window in which the current project time is displayed.
   private int maxTemp = 2400 - 200;	//The maximum temp allowed. 200 is the safety margin in which it will not add more cc.
   private int minTemp = 1600 + 200;	//The minimum temp allowed. 200 is the safety margin in which it will not start SG.
   private int delay = 1;		//Delay between checks. MS?
   private Functions functions;


   public Glass() {

//System.out.println(windowY);

functions = new Functions(windowX, windowY, numWindows, numCols);

       //functions.SetupWindows();

int red=0; int green=0; int blue=0; int pixels=tempWidth; Color color; int[] temp = new int[numWindows]; int[] oldtemp = new int[numWindows]; int i,w; boolean projectCooling=false;

System.out.println("****************");

System.out.println("YTemp: " + yTemp);

//?? while(true){ //repeats over all open windows for(w=0;w<numWindows;w++){ System.out.println(WindowNumber % NumberOfRows);

projectCooling = false;

for(i=0;i<=tempWidth;i++){ color = functions.getPixelColor(xTemp + i, yTemp, w); red = color.getRed(); green = color.getGreen(); blue = color.getBlue(); //System.out.println("Red: " + red); //System.out.println("Green: " + green); //System.out.println("Blue: " + blue); //System.out.println("-----------"); if((red-20)<green){ //Looks to see where the red stops pixels = i; //sets 'pixels' to the length of the temp bar //System.out.println("pixels: " + pixels); //temp[w] = (int)pixels*187000/10000; //System.out.println("Calculated Temperature: " + temp[w]); break; } }

//Scans the line of pixels defined by ProjectX for anything dark, which would mean a project is in progress for(i=0;i<tempWidth;i++){ color = functions.getPixelColor(xProject + i, yProject, w); red = color.getRed(); green = color.getGreen(); blue = color.getBlue(); if(blue < 30 && green < 30 && red < 30){ projectCooling = true; break; } }

if(!projectCooling && temp[w]>1600 && temp[w]<2400){ System.out.println("Starting Sheetglass" + "Window: " + w); functions.PressButton(xRefresh, yRefresh, w); functions.delay(50); functions.PressButton(xSheetglass, ySheetglass, w); }

oldtemp[w]=temp[w]; temp[w] = (int)pixels*186567/10000; if(temp[w]!=oldtemp[w]){ System.out.println("CurrentTemp: " + temp[w] + "Window: " + w); if(temp[w]<oldtemp[w] && temp[w]<maxTemp){ System.out.println("adding CC" + "Window: " + w); functions.PressButton(xCC, yCC, w); if(temp[w]<minTemp){ System.out.println("adding extra CC" + "Window: " + w); functions.PressButton(xCC, yCC, w); functions.PressButton(xCC, yCC, w); functions.PressButton(xCC, yCC, w); functions.PressButton(xCC, yCC, w); } } } }

functions.delay(50); } } public static void main(String[] args) { new Glass(); } }