//#################################### // Author: Zeja Pyle, 2015 // // GEOSCANNER v321 - Opensim // // FREE DISTRIBUTION FOR THE OPENSIM COMMUNITY // //#################################### float max; list Geo = []; string XDIGITS = "0123456789ABCDEF"; string TwoDigit(integer value){ if (value <= 9){ return "0" + (string) value; }else{ return (string) value; } } string hexes(integer bits) { string nybbles = ""; while (bits) { integer lsn = bits & 0xF; // least significant nybble string nybble = llGetSubString(XDIGITS, lsn, lsn); nybbles = nybble + nybbles; bits = bits >> 4; // discard the least significant bits at right bits = bits & 0xfffFFFF; // discard the sign bits at left } return nybbles; } string hex(integer value) { if (value < 0) { return "00"; } else if (value == 0) { return "00"; // hexes(value) == "" when (value == 0) } else // if (0 < value) { if (value <= 15){ return "0" + hexes(value); }else{ return hexes(value); } } } string Float2String ( float num, integer places, string rnd) { string neg = ""; if (num < 0.0) neg = "-"; if (places == 0) { return neg + (string) ((integer)num ); } else if (rnd != "Yes") { if ( (places = (places - 7 - (places < 1) ) ) & 0x80000000) { return llGetSubString((string)num, 0, places); } return (string)num; } else { float f = llPow( 10.0, places ); integer i = llRound(llFabs(num) * f); string s = "00000" + (string)i; // number of 0s is (value of max places - 1 ) return neg + (string)( (integer)(i / f) ) + "." + llGetSubString( s, -places, -1); } } default { state_entry() { } touch_start(integer total_number) { integer x; integer y; float xx; float yy; vector CurentPoz; float alti; string line; float min = 0; max = 255; llOwnerSay("GEO-SCAN STARTED!"); llOwnerSay("This process takes around a minute, please wait..."); for (y = 0;y<=29;y++){ for (x = 0;x<=29;x++){ CurentPoz = llGetPos(); xx = (((x + 0.5)/30)*256) - CurentPoz.x; yy = (((y + 0.5)/30)*256) - CurentPoz.y; alti = llGround(); if (alti > max){max = alti;} if (alti < min){min = alti;} } } Geo = []; for (y = 0;y<=29;y++){ line = ""; for (x = 0;x<=29;x++){ CurentPoz = llGetPos(); xx = (((x + 0.5)/30)*256) - CurentPoz.x; yy = (((y + 0.5)/30)*256) - CurentPoz.y; alti = llGround(); if (max == 0){line = line + "00";}else{line = line + hex(llFloor(((alti - min)/max)*255));} } //send the line + number here here Geo = Geo + [line]; } integer transmit = 0; string curline = ""; llSay(0,"###### COPY THIS ######"); for (transmit = 0; transmit <= 32; transmit++){ if (transmit >= 30){ if (transmit == 30){ curline = "<" + TwoDigit(transmit) + ">" + (string) max + ""; llSay(0,curline); } if (transmit == 31){ curline = "<" + TwoDigit(transmit) + ">" + (string) llWater(llGetPos()) + ""; llSay(0,curline); } if (transmit == 32){ llSay(0,"###### UP TO HERE ######"); llOwnerSay("GEO-SCAN COMPLETED!"); llOwnerSay("To generate the sculpted map texture for this region go on the web at: http://geosculpties.bashora.com?opensim.php"); } }else{ curline = "<" + TwoDigit(transmit) + ">" + llList2String(Geo,transmit) + ""; llSay(0,curline); } }//for }//event }//state