Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Problems with a radar display script.

yevka Laws
Commander Eva "Yevka" Law
Join date: 19 Jul 2006
Posts: 32
04-06-2008 13:51
Basic concept to reduce lag is simple.

A SL vehicle carries a transponder. This broadcastss a signal that says where it is in the simulator.

Instead of an active radar, the receiver merely receives and displays the information.

It is supposed to display the information on a two dimensional black "radar" screen 1 meter by 1 meter.

The dot will not move even when the transponder moves.

Here comes the code, sample data and more description:

Bids are now being taken for production of a radar system that will come as close as functionally possible to the "Dradis" from Battlestar Galactics.

Specifications:
-----------------

Scan the entire sim in all 3 axises

Scan for, and track, multiple fixed and moving targets.

Display this data on a 2D vertical surface as if looking top down onto the sim floor as a "blip". The display will be at a fixed point in the sim to be determined later.

Included in this data should be the pilot's name, position on the Z axis, and distance from the screen.

It must also have different types of markers, depending on what type of aircraft it is tracking.

The entire system, including all scripts, prims, etc. must include full copy, modify, and transfer rights.

-----------------

A fixed price for all work, including demos and testing, and a deadline date for delivery, will be mutually agreed upon. Terms and conditions of payment will be discussed with individual bidders.



Sample data
ship, AV key, name, vector

Here is the basic concept.

We have a 1 meter by 1 meter display screen, kind of like radar

we have a transponder that broadcasts position
Plane,Avatar key,yevka laws,vector

Vector is two dimensional, consists of altitude in the simulator and



LSL Code

Transponder: Broadcasts the location for the other components to pick up.

string ship;
string pilot;
key av;

string Blip_Msg;

string My_Pos;


default {
state_entry() {
llSitTarget(<0, 0, 0.5>, ZERO_ROTATION); // needed for llAvatarOnSitTarget to work
}

changed(integer change) { // either someone sat down or stood up
if (change & CHANGED_LINK) { // and it was a link change (See Bottom)
av = llAvatarOnSitTarget(); // get the key of the av who sat down

if (av) { // if someone is actually sitting down,

ship = llGetObjectDesc(); // get ship type off object description

pilot = llKey2Name(av); // change key into a name...

//llRegionSay(90210, "viper";); // Broadcast channel number to the console

llSetTimerEvent(1); // Start broadcasting my position


} else {
if (av == NULL_KEY); { // if the pilot left the ship

llRegionSay(90210, "unmanned";); // Broadcast kill signal to the console

llSetTimerEvent(0); // Stop broadcasting position

}
}
}
}


timer() {

ship = (string) llGetObjectDesc();

vector TempPos = llGetPos();
float x = (TempPos.x);
float y = (TempPos.y);
float z = (TempPos.z);

llSay(0, (string) x);
llSay(0, (string) y);
llSay(0, (string) z);

Blip_Msg = (ship + "," + (string) av + "," + pilot + "," + (string) x + "," + (string) y + "," + (string) z);
//llOwnerSay(Blip_Msg);
llRegionSay(90210, Blip_Msg);


}
}





blip:
Truly troublesome part, which is currently supposed to display a two dimensional graphic ball and move it around the radar screen as thethe transponder moves.


integer Blip_Chan;
float Ratio = .00390625;
string message;

default {
state_entry()
{
llSetObjectName("Blip";);
}

on_rez(integer start_param) {
Blip_Chan = start_param;
llListen(Blip_Chan, "", "","";);
}

listen(integer number, string name, key id, string message) {

if (message != "Die";) {

llSetTimerEvent(1);

} else {

llSay(0, "Die Message";);
llDie();
llSetTimerEvent(0);
}
}

timer() {

list src = llParseString2List(message,[","],[]);

string ship = (llList2String(src, 1));
key PilotKey = (llList2Key(src, 2));
string Pilot = (llList2String(src, 3));

float x = (llList2Float(src, 4));
float y = (llList2Float(src, 5));
float z = (llList2Float(src, 6));


vector My_Pos = llGetPos();

vector Target_Pos = <x,y,z>;

vector Scale_Pos = (Target_Pos - My_Pos) * 0.00390625; // Scale 1mm console = 1m Sim

//llSay(0, (string) (My_Pos + Scale_Pos));

llSetPos(My_Pos + Scale_Pos);

//string Range = (string) (llRound( llVecDist(My_Pos, Target_Pos ) * 10 ) / 10);

//llSetText(avName + "[" + avDistance + "]", <1, 1, 1 >, 1);



}
}

Main problem here is the blip does not move about the screen.

Suggestions welcome.
Kidd Krasner
Registered User
Join date: 1 Jan 2007
Posts: 1,938
04-06-2008 14:48
What is the question? Are you the one looking for someone to implement this, or are you bidding on this and simply copied the RFP in your post?

Oh, and the problem is that the message parameter in the listen event is hiding the global variable named message.
yevka Laws
Commander Eva "Yevka" Law
Join date: 19 Jul 2006
Posts: 32
The question
04-07-2008 05:32
Script is supposed to post a little graphic ball to a 1 meter by 1 meter screen. That ball is supposed to move when the transponder moves.

The little graphic ball, hereto called a blip is not moving.

We want code correction suggestions if possible.

Regards,

Yevka
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
04-07-2008 08:07
CODE
string ship;
string pilot;
key av;

string Blip_Msg;

string My_Pos;


default {
state_entry() {
llSitTarget(<0, 0, 0.5>, ZERO_ROTATION); // needed for llAvatarOnSitTarget to work
}

changed(integer change) { // either someone sat down or stood up
if (change & CHANGED_LINK) { // and it was a link change (See Bottom)
av = llAvatarOnSitTarget(); // get the key of the av who sat down

if (av) { // if someone is actually sitting down,

ship = llGetObjectDesc(); // get ship type off object description

pilot = llKey2Name(av); // change key into a name...

//llRegionSay(90210, "viper"); // Broadcast channel number to the console

llSetTimerEvent(1); // Start broadcasting my position


} else {
if (av == NULL_KEY); { // if the pilot left the ship

llRegionSay(90210, "unmanned"); // Broadcast kill signal to the console

llSetTimerEvent(0); // Stop broadcasting position

}
}
}
}


timer() {

ship = (string) llGetObjectDesc();

vector TempPos = llGetPos();
float x = (TempPos.x);
float y = (TempPos.y);
float z = (TempPos.z);

llSay(0, (string) x);
llSay(0, (string) y);
llSay(0, (string) z);

Blip_Msg = (ship + "," + (string) av + "," + pilot + "," + (string) x + "," + (string) y + "," + (string) z);
//llOwnerSay(Blip_Msg);
llRegionSay(90210, Blip_Msg);


}
}


CODE
integer Blip_Chan;
float Ratio = .00390625;
string message;

default {
state_entry()
{
llSetObjectName("Blip");
}

on_rez(integer start_param) {
Blip_Chan = start_param;
llListen(Blip_Chan, "", "","");
}

listen(integer number, string name, key id, string message) {

if (message != "Die") {

llSetTimerEvent(1);

} else {

llSay(0, "Die Message");
llDie();
llSetTimerEvent(0);
}
}

timer() {

list src = llParseString2List(message,[","],[]);

string ship = (llList2String(src, 1));
key PilotKey = (llList2Key(src, 2));
string Pilot = (llList2String(src, 3));

float x = (llList2Float(src, 4));
float y = (llList2Float(src, 5));
float z = (llList2Float(src, 6));


vector My_Pos = llGetPos();

vector Target_Pos = <x,y,z>;

vector Scale_Pos = (Target_Pos - My_Pos) * 0.00390625; // Scale 1mm console = 1m Sim

//llSay(0, (string) (My_Pos + Scale_Pos));

llSetPos(My_Pos + Scale_Pos);

//string Range = (string) (llRound( llVecDist(My_Pos, Target_Pos ) * 10 ) / 10);

//llSetText(avName + "[" + avDistance + "]", <1, 1, 1 >, 1);



}
}


Quoting to make code less ugly with GreaseMonkey.

Edit: One problem is that you're never actually saving a message input to make use of. All you're doing right now is setting a timer.

However, I'd scrap this system completely and do it a little differently. Instead of having constant communication, just keep a list or string containing the keys of all tracked objects. Then on a timer, run through the set of keys and fetch their positions using llGetObjectDetails. If your radar is a linked set, you can use multiple scripts to update the entire linkset very quickly, or if you just want to be lazy, have each blip prim contain its own tracking script that follows only one specific key using the same method.
_____________________