Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

State Driven Land Ownership Scanner

Kristian Ming
Head Like A Hole
Join date: 5 Feb 2005
Posts: 404
01-04-2006 18:57
Inspired by my attempts to get the script in this thread to perform as expected, I decided it was high time to teach myself states and rewrote my solution to the problem from scratch. It is a fully functioning landscanner (on touch) , and hopefully a good jumping off point for other land scanning functionality or as a straightforward example of states. :)

CODE
// State Based Land Ownership Scanner
// by Kristian Ming
// public domain: do what thou wilt shall be the whole of the law
key landowner;
key queryid;
integer timeout = 10;
integer num_detected;
string data;


default {
state_entry () {
state idle;
}

}

state idle {
state_entry () {
llSetText("Ready.\nTouch to Scan.", <0,1,0>, 1.0);
}

touch_start (integer num_detected) {
landowner = llGetLandOwnerAt(llGetPos());
if (landowner == NULL_KEY) {
llSay(0,"This land is public! Act fast!");
} else {
llRequestAgentData(landowner, DATA_NAME);
llSay(0, "Querying dataserver for Avatar name...");
state scanning;
}
}

dataserver (key queryid, string data) {
llSay(0, "Dataserver event triggered when I wasn't expecting one.");
}
}

state scanning {

state_entry () {
llSetText("Scanning...\nTouch to cancel.", <1,0,0>, 1.0);
llSetTimerEvent(timeout);
}

touch_start (integer num_detected) {
llSay(0, "Scan Cancelled.");
llSetTimerEvent(0);
state idle;
}

dataserver (key queryid, string data) {
llSay(0, "Land is owned by: " + data);
llSetTimerEvent(0);
state idle;
}

timer () {
llSay(0, "Dataserver event timeout. Land may be group owned.");
llSetTimerEvent(0);
state idle;
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
01-07-2006 09:23
/54/7a/81274/1.html
_____________________
i've got nothing. ;)