// this is actually the version of the code that works for re-reading the log file continuously while UT plays, all Ive done is disable the draw loop when it gets to the end of the log. int readlogfile =1; //1 for the first time round 2 for other times String logfile []; int numberofreads =1; //(counts the number of times the log file has been read) int linenumber =0; //counts line numbers int findfirstlevel =1; int turnstringstonumbers =1;//1 for activate turning raw logfile to int array String [] lookfor = {"ScriptLog:" , "=" }; String [] levelfind = {"Log: Precaching: DM-vin.LevelInfo0" , "Log: Precaching: DM-vin2.LevelInfo0" , "Log: Precaching: DM-jake.LevelInfo0" , "Log: Precaching: DM-jake2.LevelInfo0"}; float [] numberslist = new float [10]; //needs to be something to start with int jnscount =0; // count through "numberslist" array int secondtimeround =0;// this is for cutting the already used numbers out of the array int lengthoftimebefore = 0;//this remembers how long the logfile was last time so it can cut it off the new one float [] cutnumberslist = new float [10];//intialise the cut draw array int drawcount =0; //draw this number in array int propred =0; //the colours to draw with int propgreen =0; int propblue =0; float [] storeforline = new float [4]; // store line xny's int sflcount =0; int botnumber =0; //see below PImage pic; void setup (){ size(400,400); background (255,255,255); } void draw (){ //println(lengthoftimebefore); if (readlogfile == 1){ logfile=loadStrings("data/UT2004.log"); logfile=contract (logfile, logfile.length-1); // gets rid of reading errors later on print ("log file is "); print (logfile.length); println (" items long"); print ("Ive read the log "); print (numberofreads); println (" times"); print ("last log is "); println (logfile[logfile.length-1]); readlogfile =0; numberofreads =1; lengthoftimebefore=logfile.length; //that way we wont check for the level again the first time round }//endif if (readlogfile == 2){ numberofreads = numberofreads+1; logfile=loadStrings("//DAVE/games/UT2004/System/UT2004.log"); logfile=contract (logfile, logfile.length-1); // gets rid of reading errors later on print ("log file is "); print (logfile.length); println (" items long"); print ("Ive read the log "); print (numberofreads); println (" times"); print ("last log is "); println (logfile[logfile.length-1]); readlogfile =0; turnstringstonumbers =1; }//endif if (findfirstlevel ==1){ int i =0; while(ilengthoftimebefore){//if were above the last read of the textfile see if we have a level change if (logfile[linenumber].equals(levelfind[0]) == true){//if vin is playing load vin println ("playing vin"); pic = loadImage("vin.jpg"); loadPixels(); fill(255,255,255); noStroke(); ellipse(312,312,1500,1500); }//endif if (logfile[linenumber].equals(levelfind[1]) == true){//if vin2 is playing load vin2 println ("playing vin2"); pic = loadImage("vin2.jpg"); loadPixels(); fill(255,255,255); noStroke(); ellipse(312,312,1500,1500); }//endif if (logfile[linenumber].equals(levelfind[2]) == true){//if jake is playing load jake println ("playing jake"); pic = loadImage("jake.jpg"); loadPixels(); fill(255,255,255); noStroke(); ellipse(312,312,1500,1500); }//endif if (logfile[linenumber].equals(levelfind[3]) == true){//if jake2 is playing load jake2 println ("playing jake2"); pic = loadImage("jake2.jpg"); loadPixels(); fill(255,255,255); noStroke(); ellipse(312,312,1500,1500); }//endif }//endif linenumber = linenumber+1; }//end else }//endwhile numberslist = contract(numberslist, jnscount); print ("numbers array is "); print(numberslist.length); println( " long"); print ("the first value is "); println(numberslist[0]); print ("the last value is "); println(numberslist[numberslist.length-1]); int remainder = numberslist.length%3; if (remainder == 0){ //if 3 goes into the length of the numbers list with no remainder then println ("no remainder");//draw allpoints np with logfilesize or numberslist size }else{//endif else println (numberslist[numberslist.length-remainder-1]);//need to minus an extra 1 because of array .length needs -1 just to get it to normal print ("remainder "); println (remainder);//if it equals 0 then it must have been something like 0.234234 numberslist = contract (numberslist, numberslist.length-remainder); // take the last 1 or 2 numbers away end on a z logfile = contract (logfile , logfile.length-remainder); //were chainging the log file like this so on the next read we start at an x print ("in convert rem loop last line now equals "); println (numberslist[numberslist.length-1]); }//endelse cutnumberslist = expand (cutnumberslist , numberslist.length); arraycopy (numberslist , cutnumberslist); //copy numberslist to cutnumberslist (there was no need for a cut this time but we need to make sure these things are called the same each time round print ("length of cut list = "); println (cutnumberslist.length); println (cutnumberslist[cutnumberslist.length-1]); turnstringstonumbers =0; //dont do this section again till later linenumber = 0; //reset for next time jnscount =0; }//endif if (secondtimeround == 1){ int newarraysize=numberslist.length-lengthoftimebefore; print ("the size of the cut array is "); println (newarraysize); int startfromhere = numberslist.length-newarraysize; cutnumberslist = expand (cutnumberslist, newarraysize); arraycopy(numberslist, startfromhere, cutnumberslist, 0, newarraysize); print ("the first number cut array is "); println (cutnumberslist[0]); print ("the last number in cut array is "); println (cutnumberslist[cutnumberslist.length-1]); int remainder = cutnumberslist.length%3; if (remainder == 0){ //if 3 goes into the length of the numbers list with no remainder then println ("no remainder");//draw allpoints np with logfilesize or numberslist size }else{//endif else print ("remainder");println (remainder);//if it equals 0 then it must have been something like 0.234234 cutnumberslist = contract (cutnumberslist, cutnumberslist.length-remainder); // take the last 1 or 2 numbers away end on a z logfile = contract (logfile , logfile.length-remainder); //were chainging the log file like this so on the next read we start at an x print ("in cut rem loop last line now equals "); println (cutnumberslist[cutnumberslist.length-1]); }//endelse secondtimeround =0; }//endif //////////////////////////////// the drawing //positions fixed (no minus') and scaled float temp1 = cutnumberslist[drawcount]; float temp2 = cutnumberslist[drawcount+1]; float temp3 = cutnumberslist[drawcount+2]; temp1 = temp1+10000; temp2 = temp2+10000; temp3 = temp3+10000; temp1 = temp1/50; temp2 = temp2/50; temp3 = temp3/50; temp3 = temp3*6; //find the colour needed // image is 625 by 625 so 390625 items in array int x = int(temp1); int y = int(temp2); y=y-1; if (y<0){ //we may have wanted the absolute top line, stops errors y=0; } y=y*400; int arraycolour = y+x;//finds the right value in the array color c = pic.pixels[arraycolour]; float thered =red(c); float thegreen =green(c); float theblue = blue (c); propred = int(thered); propgreen = int(thegreen); propblue = int(theblue); float redrand = random(20); int theredrand = int(redrand); float greenrand = random(20); int thegreenrand = int(greenrand); float bluerand = random(20); int thebluerand = int(bluerand); propred = propred+theredrand; propgreen = propgreen+thegreenrand; propblue = propblue+thebluerand; if (propred>255){ propred =255; } if (propgreen>255){ propgreen =255; } if (propblue>255){ propblue =255; } // now lets draw summit if (sflcount<=3){ //the first time round on a map storeforline[sflcount]=temp1; storeforline[sflcount+1]=temp2; sflcount=sflcount+2; //store the first x and y values of the line }else{ //draw full line (the final xy of a line becomes the first xy of the next stroke(propred, propgreen, propblue, 25);//added an alpha to make the lines look better smooth(); line(storeforline[0],storeforline[1],storeforline[2],storeforline[3]); sflcount = 4;//dont do the top bit again storeforline[0]= storeforline[2]; storeforline[1]= storeforline[3]; storeforline[2]=temp1; storeforline[3]=temp2; } fill(propred, propgreen, propblue); noStroke(); smooth(); ellipse(temp1, temp2, temp3, temp3); fill(255,255,255); noStroke(); smooth(); ellipse(temp1,temp2,1,1); /////////////////////////////// drawcount = drawcount+3; botnumber = botnumber+1; if (botnumber == 15){//number of bots that should play per second delay(800); botnumber=0; } if (drawcount >= cutnumberslist.length-1){//This would be where the re-read takes place... this time were just bringing a noloop println ("LOOPING"); println ("actually no were not! we have no more log to read, were on a website"); noLoop(); /* //tihngs to be set nexttimeround readlogfile=2; // wanna read the logfile when fnished turnstringstonumbers=1; // wanna make sure we play turn strings to num when finished secondtimeround =1; //makesure we do this on the next read, cut the array up so we dont repeat points //println (logfile.length); lengthoftimebefore = numberslist.length; //resets drawcount =0; */ } //end if }//end draw