Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Hide/Show Hovertext?

Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
06-12-2009 19:44
I can't, for the life of me, find a good way to hide hovertext.

I've got a freebie radar script that I stuck in a prim that I wear. It works great, displays all avatars within 96 meters as hovertext, with distance and direction.

But I'd love to be able to click it on and off, so it's not displaying ALL the time. Anyone know an easy way to do that?
Papalopulus Kobolowski
working mind
Join date: 11 Aug 2006
Posts: 326
06-12-2009 20:11
With out know how its your radar script its not posible to tell you how exactly you can acomplish that but basically you need to change some parte in your code.

something liek this :

llSetText("your radar info ..bla bla bla", <1.0, 1.0, 1.0>, 1.0);

to

llSetText("", <1.0, 1.0, 1.0>, 1.0);

or directly stop the radar and wipeout the hover text.

with a touch event for example.


_____________________


RAW terrain files - terraform your SIM!!
http://www.wishland.info/
PD:the wiki its your friend ;)
http://wiki.secondlife.com/wiki/LSL_Portal
Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
06-12-2009 20:19
Yeah, it's a pretty complex script... It's open source from the wiki, I'll add it to show it. But the other option I considered was rezzing/unrezzing the prim containing the script with a click or a menu. Is that very hard to set up?



CODE


//Sable Till - Radar/scannar script.
//You can get a copy of the license this script is under at http://www.gnu.org/copyleft/gpl.html
//Copyright (C) 2006 Sable Till

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

string status="none";
list people;
integer maxScanDistance=96;
vector color = <0,1,1>;
integer maxPeople = 8;
integer scanType = AGENT;
integer scanFreq=1;
integer scanDistance=96;

integer count(string name) {
integer i = llListFindList(people, [name]);
if(i ==-1){
people+=[name, 0];
return 0;
} else {
integer count = llList2Integer(people, i+1);
people=llListReplaceList(people, [count+scanFreq], i+1, i+1);
return count;
}
}

//calculate time strings with proper units that are sensibly rounded
string time(integer cnt) {
if(cnt>3600) {
return (string)(cnt/3600)+"hr " + (string)((cnt%3600)/60) +"min";
}else {
if(cnt>60) {
return (string)(cnt/60)+"min";
} else {
return (string)cnt+"s";
}
}
}
//I'm pretty sure there's a better way to do this but I'm trying to calculate the angle between
//North and the target so I can work out which direction it is in.
float getAngle(vector me, vector target) {
float hyp = llVecDist(me, target);
float yDiff = target.y-me.y;
float xDiff = target.x-me.x;
float angle = llSin(yDiff/hyp);
if(xDiff>0 && yDiff>0) {
return angle*RAD_TO_DEG;
}
if(xDiff>0 && yDiff<0) {
return 90-angle*RAD_TO_DEG;
}
if(xDiff<0 && yDiff>0) {
return angle*RAD_TO_DEG+270;
}
if(xDiff<0 && yDiff<0) {
return angle*RAD_TO_DEG + 270;
}
return angle*RAD_TO_DEG;
}

default
{
state_entry()
{
llSensorRepeat("", "",scanType, scanDistance, PI, scanFreq);
llSetTimerEvent(15);
}

sensor(integer num_detected) {
people=[];
string result;
integer n=-1;
integer distance=0;
integer detDist;
string name;

vector pos = llGetPos();
//get the dist, name and direction of everyone we just scanned.
for(n=0;n<num_detected && n<maxPeople;++n) {
vector detPos = llDetectedPos(n);
detDist = (integer)llVecDist(pos, detPos);
float angle = getAngle(llGetPos(), detPos);
name = llKey2Name(llDetectedKey(n));
if(detDist<96) {
people+=detDist;
people+=name;
people+=angle;
}
}
//sort the strided list
people = llListSort(people, 3, TRUE);
//construct settext
num_detected = llGetListLength(people)/3;
for(n=0;n<num_detected;++n) {
detDist=llList2Integer(people, n*3);
name = llList2String(people, n*3+1);
float dir = llList2Float(people, n*3+2);
if(detDist>20 && distance<=20) {
result+="<- Chat Range Limit ->\n";
}
result+=name;
if(detDist<20) {
integer cnt = count(name);
result+=" ["+time(cnt)+"]";
}
result+=" ["+(string)detDist+"m]";

if(dir < 0 || dir > 360) {
llOwnerSay("Error:"+(string)dir+":"+name);
}
//determine which compass direction they are in.
if(dir <= 22.5) {
result+=" N\n";
} else {
if(dir > 22.5 && dir <= 67.5) {
result+=" NE\n";
} else {
if(dir > 67.5 && dir <= 112.5) {
result+=" E\n";
} else {
if(dir > 112.5 && dir <= 157.5) {
result+=" SE\n";
} else {
if(dir > 157.5 && dir <= 202.5) {
result+=" S\n";
} else {
if(dir > 202.5 && dir <= 247.5) {
result+=" SW\n";
} else {
if(dir > 247.5 && dir <= 292.5) {
result+=" W\n";
} else {
if(dir > 292.5 && dir <= 337.5) {
result+=" NW\n";
} else {
if(dir > 337.5 && dir < 360) {
result+=" N\n";
}
}
}

}}}}}}

distance=detDist;
}

//If we detected more (or the same number of) people as maxPeople then shrink down the scan distance to just
//the distance to the furthest one. Otherwise increment it a bit in case there are people further out.
if(num_detected>=maxPeople) {
scanDistance=distance+10;
llSensorRepeat("", "",scanType, scanDistance, PI, scanFreq);
} else {
if(scanDistance<maxScanDistance) {
scanDistance+=10;
llSensorRepeat("", "",scanType, scanDistance, PI, scanFreq);
}
}

result+="\nStatus:" + status + ":" + (string)scanFreq + ":" + (string)scanDistance + ":" + (string)maxScanDistance;
//adjust max people based on the length of result
if(llStringLength(result)>254) {
maxPeople--;
llOwnerSay("Length is "+(string)llStringLength(result) +
" Decrementing maxPeople to "+(string)maxPeople);
} else {
if(llStringLength(result)<200 && num_detected>maxPeople) {
maxPeople++;
llOwnerSay("Length is "+(string)llStringLength(result) +
" Incrementing maxPeople to "+(string)maxPeople);
}
}
llSetText(result, color, 1);
}

no_sensor() {
llSetText("Status:"+status, color, 1);
maxScanDistance+=10;
llSensorRepeat("", "", scanType, maxScanDistance, PI, scanFreq);
}

//all we do here is check the sims fps and dilation and tone down our scanning if necessary.
timer() {
float fps = llGetRegionFPS();
float timeDilation = llGetRegionTimeDilation();

if(fps<35 || timeDilation <0.9) {
maxScanDistance=32;
if(scanDistance>maxScanDistance) {
scanDistance=maxScanDistance;
}
scanFreq=240;
status = "poor";
llSetTimerEvent(240);
color=<1,0,0>;
} else
{
//sim is slightly lagged, we scan every 120seconds and to a max of 64metres
if(fps<40 || timeDilation<0.95) {
maxScanDistance=64;
if(scanDistance>maxScanDistance) {
scanDistance=maxScanDistance;
}
scanFreq=30;
status = "ok";
llSetTimerEvent(120);
color=<1,1,0>;
} else
//sim is fine, we scan every second and to the max distance possible
{
maxScanDistance=96;
if(scanDistance>maxScanDistance) {
scanDistance=maxScanDistance;
}
scanFreq=1;
llSetTimerEvent(60);
status = "good";
color=<0,1,1>;
}}
llSensorRepeat("", "", scanType, scanDistance, PI, scanFreq);
}
}

Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
06-12-2009 22:02
You could either make state changes in the original script to turn the radar off and set the hover text or you could take the easy route and add the following in a second script. This will turn the radar script off and blank out the hover text when you touch it and then turn the radar script back on when you touch it again.

CODE

integer switch = 1;

default
{
touch_start(integer total_number)
{
if(switch == 1)
{
llSetScriptState("name of your radar script here", FALSE);
llSetText("", <1.0, 1.0, 1.0>, 1.0);
switch = 0;
}
else
{
llSetScriptState("name of your radar script here", TRUE);
switch = 1;
}
}
}
_____________________
There are no stupid questions, just stupid people.
Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
06-12-2009 22:25
From: Laurence Corleone
You could either make state changes in the original script to turn the radar off and set the hover text or you could take the easy route and add the following in a second script. This will turn the radar script off and blank out the hover text when you touch it and then turn the radar script back on when you touch it again.

CODE

integer switch = 1;

default
{
touch_start(integer total_number)
{
if(switch == 1)
{
llSetScriptState("name of your radar script here", FALSE);
llSetText("", <1.0, 1.0, 1.0>, 1.0);
switch = 0;
}
else
{
llSetScriptState("name of your radar script here", TRUE);
switch = 1;
}
}
}


That's absolutely awesome, better than I expected.
Rygel Ryba
Registered User
Join date: 12 Feb 2008
Posts: 254
06-13-2009 00:42
Yep. That's much better - and will also help with lag. Radar scripts (the scan function in particular) adds a fair amount of script lag. So just turning off the float text is wasting a lot of resources. This method here will actually shut down all the scan functions too.

If you are interested, I make a free HUD that is primarily for use with our hypnosis machines, but over the past year I've started to add a lot of the various scripts and gadgets that most people have all into the same HUD so you don't have 100 attach points used up. It has a simple scanner (yep, it turns on and off lol), ZHAO-II AO, and, the coolest thing in it is an Outfit Manager (that needs Restrained Life Viewer - but it really has nothing to do with Restraints lol) where you can set up folders in a certain way and change outfits, strip naked (ooooo), and get dressed all with a few menu clicks.

https://www.xstreetsl.com/modules.php?name=Marketplace&file=item&ItemID=1331215

It's slowly becoming my most frequently used tool in SL - and every time I decide to add something new I mutter things under my breath about why I decided to make it free. lol
Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
06-13-2009 01:08
Yeah, I got it working, it's great.

Seems like every day I learn a ton more here about scripts. It's way too much fun to stop.