This is in relation to a simple "HUD scanner" script... the kind that once a second scans for avatars in the area and shows a list of them, using float text, above an invisible prim attached to a HUD point. There's nothing mysterious about this; these things have been around forever. What is mystifying me is this:
For my purposes, the float text needs to always start at a certain height on the screen, and the list grows downwards as more people are added to it. That's fairly straightforward. If I use a loop to add newline characters to pad out the string for the float text, it works fine. If instead of a loop I use llGetSubString to take a piece of a string containing nothing but newline characters and tack it on to the end of the string for the float text... they don't show up. But if that same string is displayed another way (via, say, llOwnerSay) the blank spacing newlines show up!
This has me scratching my head.
Here's the script:
CODE
string spacer = "\n\n\n\n\n\n\n\n\n\n\n\n";
default
{
state_entry()
{
llSetText("",<0,0,0>,1);
llSensorRepeat("",NULL_KEY,AGENT,96,PI,1);
}
link_message(integer sender, integer num, string msg, key id)
{
if (msg == "sensor off")
{
llSensorRemove();
llSetText("",<0,0,0>,1);
}
else if (msg == "sensor on")
{
llSensorRepeat("",NULL_KEY,AGENT,96,PI,1);
}
}
sensor(integer num_detected)
{
string title = "";
integer distance;
integer x;
integer count = 0;
if ( num_detected > 12 )
{
num_detected = 12;
}
for( x = 0; x < num_detected ; x++ )
{
distance = llFloor(llVecDist(llGetPos(),llDetectedPos(x)));
if ( distance < 96 )
{
title += (string)llDetectedName(x)+" ("+(string)distance+"m)\n";
count ++;
}
}
// title = title + llGetSubString(spacer, count, 12);
// To see the odd behavior, comment out the following line and un-comment the prior line
for( x = count; x < 13 ; x ++ ) title = title + " \n";
llSetText(title,<1,1,1>,1);
}
no_sensor()
{
llSetText("",<1,1,1>,1);
}
}
. text has a length limit of 255 characters.