Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

view text in mouselook

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-11-2007 10:29
it is a kind of complex idea im working on, when you are in mouselook within a plane you will be able to see the text on the hud but when not in mouselook you wont be able to see it, i had it nearly working a few times but when i go into mouselook it dosent show up atall not sure if this way is the currect way of doing it

CODE

integer display = TRUE;

vector pos;
string altitude;
string altitude_sea;
string text;
vector Euler;
integer heading;
integer afterburner;
vector velocity;
string speed;
string throttle;
vector fwd;
rotation rot;

default
{
state_entry()
{
llSetText(" ", <1.0, 1.0, 1.0>, 0.0);
afterburner = FALSE;
}

link_message(integer sender, integer num, string str, key id)
{
if (str == "start") {
state active;
} else if (str == "throttle") {
throttle = (string)num;
} else if (str == "display off") {
display = FALSE;
} else if (str == "display on") {
display = TRUE;
}
}
}

state active
{
state_entry()
{
if (display) {
llSetTimerEvent(0.5);
}
}

state_exit()
{
llSetTimerEvent(0.0);
}

on_rez(integer sparam)
{
state default;
}

timer()
{
if (display) {
pos = llGetPos() + (llGetVel() / 2.0);
pos = llGetPos();

if (afterburner) {
text = "Throttle: AFTERBURNER";
} else {
text = "Throttle: " + throttle + "%";
}

velocity = llGetVel();
speed = (string)llVecMag(velocity);
speed = llGetSubString(speed, 0, llSubStringIndex(speed, ".") + 3);
text += " - Speed: " + speed + " m/s";

rot = llGetRot();
fwd = llRot2Up(rot * llRotBetween(llRot2Fwd(rot), <0.0, 0.0, 1.0>)) * -1.0;
heading = llFloor((llAtan2(fwd.x, fwd.y) * RAD_TO_DEG) + 0.5);
if (heading < 0) {
heading += 360;
}
text += " - Heading: " + (string)heading + " degrees";

text += "\n----------";

altitude = (string)pos.z;
altitude = llGetSubString(altitude, 0, llSubStringIndex(altitude, ".") + 3);
altitude_sea = (string)(pos.z - llWater(ZERO_VECTOR));
altitude_sea = llGetSubString(altitude_sea, 0, llSubStringIndex(altitude_sea, ".") + 3);
text += "\nAltitude (abs): " + altitude + " meters";
text += "\nAltitude (sea): " + altitude_sea + " meters";

text += "\nCoordinates: " + (string)llFloor(pos.x) + ", " + (string)llFloor(pos.y) + " (" + llGetRegionName() + ")";
if(llGetAgentInfo(llGetOwner())& AGENT_MOUSELOOK) // added
{
llSetText(text + "\n ", <0.25, 0.25, 1.0>, 1.0); //added
}
} else {
llSetTimerEvent(0.0);
llSetText(" ", <0.25, 0.25, 1.0>, 0.0); //added
}
}
}

link_message(integer sender, integer num, string str, key id)
{
if (str == "stop" || str == "crash") {
state default;
} else if (str == "throttle") {
throttle = (string)num;
} else if (str == "afterburner_hud") {
afterburner = TRUE;
} else if (str == "afterburner_hud_off") {
afterburner = FALSE;
} else if (str == "display off") {
display = FALSE;
} else if (str == "display on") {
display = TRUE;
llSetTimerEvent(0.25);
}
}
}


i was also trying to wire the mouselook with display integers and had no luck
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
11-11-2007 11:05
i would remove your added part and make a 2nd script with the llGetAgentInfo
and send llMessageLinked "display off" "display on" to turn on and off
thats what the script was designed for and already has the link_message event
-LW
_____________________
L$ is the root of all evil
videos work! thanks SL :)
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-11-2007 11:35
this was aorrinaly a freebie script that i heavyly modded not sure if it will interact with the other stuff i added, but ill give it a shot
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-11-2007 12:19
i made a second script for it and it refuses to work right every time i go into mouse look it shows up but it only saposed to work when im seated inside the plane and have mouselook

CODE

integer sit;

default
{
state_entry()
{
llSetTimerEvent(.2);
}
link_message(integer sender, integer num, string str, key id)
{
if(str="seated")
{
sit=TRUE;
}
else if(str="unseated")
{
sit=FALSE;
}
}
timer()
{
if((llGetAgentInfo(llGetOwner())& AGENT_MOUSELOOK) && (sit=TRUE))
{
llMessageLinked(LINK_SET, 0, "start", "");
}
else
{
llMessageLinked(LINK_SET, 0, "stop", "");
}
}
}