Open sourced Land ownership scanner, 95% complete please help
|
|
Jackson Rickenbacker
Registered User
Join date: 8 Oct 2006
Posts: 601
|
10-22-2007 06:33
I been trying to make this land scanner work forever now. seems that everything works fine except getting avatar names from the keys, doing something wrong in the dataserver. Can anyone take a look and help? list owner_keys; list owner_names; list owner_parcels; key DS_QUERYID;
integer MAP_SIZE = 64; integer owner_length; string current_owner;
string sim_host; string sim_name;
scan_land() {
// PREPARE SCAN START llOwnerSay( "Simulator scan started... please wait." ); llSetText( "Retrieving simulator name and host... please wait", <1.0, 0.0, 0.0>, 1.0 ); owner_keys = owner_names = owner_parcels = []; //sim_host = llGetSimulatorHostname(); sim_name = llGetRegionName(); // PREPARE SCAN END // LAND SCAN START integer x; integer y; for( y = 0; y < MAP_SIZE; y++ ) { for( x = 0; x < MAP_SIZE; x++ ) { key land_owner = llGetLandOwnerAt( < ((float)x * 4.0 + 2.0), ((float)y * 4.0 + 2.0), 0.0 > ); integer idx = llListFindList( owner_keys, [ land_owner ] ); if( idx != -1 ) { integer land = llList2Integer( owner_parcels, idx ) + 16; owner_parcels = llListReplaceList( owner_parcels, [land], idx, idx ); } else { owner_keys += [ land_owner ]; owner_parcels += 16; } } integer percent_done = (integer)(100.0 / (float)MAP_SIZE * ((float)y + 1.0)); llSetText( "Simulator scan in progress ... " + (string)percent_done + "% done\nTotal land scanned "+ (string)(((float)x * 4.0 + 2.0)*((float)y * 4.0 + 2.0))+"sqm", <1.0, 0.0, 0.0>, 1.0 ); } // LAND SCAN END // get number of owners scanned owner_length = llGetListLength( owner_keys ); // SCAN KEYS START integer i; for( i = 0; i < owner_length; i++ ) { key current_UUID = llList2Key(owner_keys, i); integer percent_done = (integer)(((i+1)/owner_length )*100); llSetText( "Working...\nTesting key " + (string)(i+1) + " of " + (string)owner_length + ": " + (string)current_UUID + "\n" + (string)percent_done + "% done", <1.0, 0.0, 0.0>, 1.0 );
llSetTimerEvent(5); DS_QUERYID=llRequestAgentData(current_UUID, DATA_NAME);
} // SCAN KEYS END // Saved to wesbite START integer j; // for( j = 0; j < llGetListLength(owner_keys); j++ ) for( j = 0; j < owner_length; j++ ) { llOwnerSay(llList2String(owner_keys, j)+"; OwnerName="+llList2String(owner_names, j)+"; LandSize="+llList2String(owner_parcels, j) );
// llSetTimerEvent(5); // DS_QUERYID=llRequestAgentData(llList2Key(owner_keys, j), DATA_NAME); // llOwnerSay("Owner is "+ current_owner ); llHTTPRequest( "http://www.xxx.com/xxx.php", [HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"], "SimName="+sim_name + "&OwnerKey="+llList2String(owner_keys, j) + "&OwnerName="+llList2String(owner_names, j) + "&ParcelSize="+llList2String(owner_parcels, j) ); } llSetText( "Simulator scan complete", <1.0, 0.0, 0.0>, 1.0 ); llOwnerSay( "Simulator scan finished. The land appears to belong to " + (string)owner_length + " owner(s)." ); // Saved to wesbite END
} //end of function scan_land()
default { touch_start( integer ContactsTotal ) { scan_land(); sim_name = llGetRegionName(); llOwnerSay("Scanned " + sim_name); }
on_rez(integer a) { llResetScript(); } dataserver(key queryid, string data) { if (queryid==DS_QUERYID) { llSetTimerEvent(0); owner_names += [ data ]; current_owner = data;
} }
timer() { llSetTimerEvent(0); owner_names += "Group Owned"; current_owner = "Group Owned"; } }
|
|
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
|
10-22-2007 09:14
For starters, try commenting out "SCAN KEYS END".
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-22-2007 10:32
Quite a few problems with it. Input it into lslint and start correcting the mistakes per the analysis.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Jackson Rickenbacker
Registered User
Join date: 8 Oct 2006
Posts: 601
|
10-22-2007 11:07
Script revised to compile correctly , but stil cant get the dataserver to spit out names from the keys
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
10-22-2007 11:52
Once your x,y scan of the sim is finished you move onto scanning the keys for names. This is where the script logic is in error. The data flow isn't quite what you expected, you've set up a for loop in which you request the name of the key. As you're doing this in a for loop the dataserver event doesn't get called until you've finished your scan_land() function. Since you're overwriting the queryid every iteration of the for loop you lose that value and the dataserver event doesn't recognise the queryid. Instead you should generate a new list for with each of the entries being a queryid which corresponds to an avatar key and their associated land quantity. Also, this means your timer event will not work as expected, instead I suggest you complete the scan and set a timer for 5 seconds, then when that triggers you fill in all the blank spaces in your list with "group land" and fire off your HTTPRequest to your server with the data.
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Jackson Rickenbacker
Registered User
Join date: 8 Oct 2006
Posts: 601
|
10-22-2007 12:03
OK Im following that, kinda, I set up the loops cause it was only returning one name from the keys, made the problem worse, I'll have to figure out another way around, maybe then I can proceed
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
10-22-2007 12:11
list owner_keys; list owner_names; list owner_parcels; list DS_QUERYID;
integer MAP_SIZE = 64; integer owner_length; string current_owner;
string sim_host; string sim_name;
scan_land() { // PREPARE SCAN START llOwnerSay( "Simulator scan started... please wait." ); llSetText( "Retrieving simulator name and host... please wait", <1.0, 0.0, 0.0>, 1.0 ); owner_keys = owner_names = owner_parcels = DS_QUERYID = []; //sim_host = llGetSimulatorHostname(); sim_name = llGetRegionName(); // PREPARE SCAN END // LAND SCAN START integer x; integer y; key land_owner; // personally I don't like creating new variables within loops, just doesn't seem efficient to me. integer idx; // however I could be entirely wrong. integer land; integer percent_done; for( y = 0; y < MAP_SIZE; y++ ) { for( x = 0; x < MAP_SIZE; x++ ) { land_owner = llGetLandOwnerAt( < ((float)x * 4.0 + 2.0), ((float)y * 4.0 + 2.0), 0.0 > ); idx = llListFindList( owner_keys, [ land_owner ] ); if( idx != -1 ) { land = llList2Integer( owner_parcels, idx ) + 16; owner_parcels = llListReplaceList( owner_parcels, [land], idx, idx ); } else { owner_keys += [ land_owner ]; owner_parcels += 16; } } percent_done = (integer)(100.0 / (float)MAP_SIZE * ((float)y + 1.0)); llSetText( "Simulator scan in progress ... " + (string)percent_done + "% done\nTotal land scanned "+ (string)(((float)x * 4.0 + 2.0)*((float)y * 4.0 + 2.0))+"sqm", <1.0, 0.0, 0.0>, 1.0 ); } // LAND SCAN END // get number of owners scanned owner_length = llGetListLength( owner_keys ); // SCAN KEYS START integer i; key DS_QUERYID_TEMP; key current_UUID; integer percent_done; for( i = 0; i < owner_length; i++ ) { current_UUID = llList2Key(owner_keys, i); percent_done = (integer)(((i+1)/owner_length )*100); llSetText( "Working...\nTesting key " + (string)(i+1) + " of " + (string)owner_length + ": " + (string)current_UUID + "\n" + (string)percent_done + "% done", <1.0, 0.0, 0.0>, 1.0 ); DS_QUERYID_TEMP=llRequestAgentData(current_UUID, DATA_NAME); DS_QUERYID += (list)DS_QUERYID_TEMP; // add this queryid to the list. } // SCAN KEYS END llSetTimerEvent(5); // for group land check then send_data } //end of function scan_land()
send_data() { // Saved to wesbite START integer j; // for( j = 0; j < llGetListLength(owner_keys); j++ ) for( j = 0; j < owner_length; j++ ) { llOwnerSay(llList2String(owner_keys, j)+"; OwnerName="+llList2String(owner_names, j)+"; LandSize="+llList2String(owner_parcels, j) ); llHTTPRequest( "http://www.xxx.com/xxx.php", [HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"], "SimName="+sim_name + "&OwnerKey="+llList2String(owner_keys, j) + "&OwnerName="+llList2String(owner_names, j) + "&ParcelSize="+llList2String(owner_parcels, j) ); } llSetText( "Simulator scan complete", <1.0, 0.0, 0.0>, 1.0 ); llOwnerSay( "Simulator scan finished. The land appears to belong to " + (string)owner_length + " owner(s)." ); // Saved to wesbite END }
default { touch_start( integer ContactsTotal ) { scan_land(); sim_name = llGetRegionName(); llOwnerSay("Scanned " + sim_name); } on_rez(integer a) { llResetScript(); } dataserver(key queryid, string data) { integer index = llListFindList(DS_QUERYID, [queryid]); if (index) { //llListReplaceList(owner_names, owner_names,0,-1); // stumped myself here, how do we take an owner_name and insert it into a list at location 'index'? especially if that means leaving blank spaces. //owner_names += [ data ]; //current_owner = data; } } timer() { llSetTimerEvent(0); //for each instance in the owner_names list which is empty, replace with "Group Owned" //...? current_owner = "Group Owned"; send_data(); }
}
Just after posting that I decided it might be best to illustrate my thoughts (which incidentally won't be the only approach and may not be the /best/ approach either). Unfortunately the code above is incomplete (and not tested). There is a gap where I didn't have sufficient time to figure out how to insert the owner name into a list at a certain 'index' position. This is key to getting the name:amount of land relationship and similarly tricky is the replacing empty locations in the list with "group owned". If you're up to it crack on, if not, maybe I'll come up with the solution when I get back. 
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Jackson Rickenbacker
Registered User
Join date: 8 Oct 2006
Posts: 601
|
10-22-2007 13:31
Thanks Nand Nerd, Its working 100%
|