Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

use of XyText for countdown timer in seconds - is there a more performant way?

Greg Hauptmann
Registered User
Join date: 30 Oct 2005
Posts: 283
02-12-2006 23:08
Hi,

I want part of my XyText display (5 faces/prim, single texture/face) to show a countdown timer, which updates every say 5 seconds (ideally 1 second), however the requests through the XyText drivers seem to be taking their toll (i.e. timer event which triggers every 5 seconds then sends request to xytext driver) and also XyText texture changes too take a little bit.

Is there a better way to implement a per second countdown timer, analog, that is setup in a displayboard/scoreboard type manner?

E.g it would show "remaining time = 12 seconds", "remaining time = 10 seconds", etc and count down.


Tks
Greg
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
02-12-2006 23:55
one second timers are hell on the system, but are more accurate than a llSleep(1); its up to you on that part.

if all your using xy text for is a timer you could make your own version of it to just deal with numbers, i have one thats a memory whore but it can display upto 999999 on a 3 faced prim (its memory intense becuase i have all the offsets in a list, i didnt make the texture square if you will) but its still 10 times faster than using the stock full xy text, for its intended use.

I sometime will remake it.. but it hasnt happened yet
for an example

/54/e5/65185/1.html

and if everyone wants to have a good laugh at a script i made almost a year ago, when i was learning the magic of lsl
CODE

integer high;
integer mid;
integer low;
string number;
//Functions
sort()
{
if ((integer)number <= 999 && (integer)number > 0)
{
high = (integer)llGetSubString(number, 0, 1);
mid = (integer)llGetSubString(number, 2, 2);
one_hu();
}
else if ((integer)number <= 9999 && (integer)number > 999)
{
high = (integer)llGetSubString(number, 0, 0);
mid = (integer)llGetSubString(number, 1, 2);
low = (integer)llGetSubString(number, 3, 3);
one_k();
}
else if ((integer)number <= 99999 && (integer)number > 9999)
{
high = (integer)llGetSubString(number, 0, 1);
mid = (integer)llGetSubString(number, 2, 3);
low = (integer)llGetSubString(number, 4, 5);
ten_k();
}
else if ((integer)number <=999999 && (integer)number > 99999)
{
high = (integer)llGetSubString(number, 0, 1);
mid = (integer)llGetSubString(number, 2, 3);
low = (integer)llGetSubString(number, 4, 5);
hu_k();
}
}

one_hu()
{
llOffsetTexture(llList2Float(X, high ), llList2Float(Y, high ),0);
llOffsetTexture(llList2Float(X, (mid *10)), llList2Float(Y, (mid *10)),2);
}

one_k()
{
llOffsetTexture(llList2Float(X, high), llList2Float(Y, high),4);
llOffsetTexture(llList2Float(X, mid ), llList2Float(Y, mid ),0);
llOffsetTexture(llList2Float(X, (low *10)), llList2Float(Y, (low *10)),2);
}

ten_k()
{
llOffsetTexture(llList2Float(X, high), llList2Float(Y, high),4);
llOffsetTexture(llList2Float(X, mid ), llList2Float(Y, mid ),0);
llOffsetTexture(llList2Float(X, (low *10)), llList2Float(Y, (low *10)),2);
}

hu_k()
{
llOffsetTexture(llList2Float(X, high), llList2Float(Y, high),4);
llOffsetTexture(llList2Float(X, mid ), llList2Float(Y, mid ),0);
llOffsetTexture(llList2Float(X, low ), llList2Float(Y, low ),2);

l

// offset float data
list X = [0.45, -0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45,
-0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45,
-0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45,
-0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45,
-0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45];

list Y = [0.55, -0.55, -0.55, -0.55, -0.55, -0.55, -0.55, -0.55, -0.55, -0.55, -0.55,
0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35,
0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15,
0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05];
default
{
state_entry()
{
X += [-0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45,
-0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45,
-0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45,
-0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45,
-0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35];
Y += [-0.05, -0.05, -0.05, -0.05, -0.05, -0.05, -0.05, -0.05, -0.05, -0.05,
-0.15, -0.15, -0.15, -0.15, -0.15, -0.15, -0.15, -0.15, -0.15, -0.15,
-0.25, -0.25, -0.25, -0.25, -0.25, -0.25, -0.25, -0.25, -0.25, -0.25,
-0.35, -0.35, -0.35, -0.35, -0.35, -0.35, -0.35, -0.35, -0.35, -0.35,
-0.45, -0.45, -0.45, -0.45, -0.45, -0.45, -0.45, -0.45, -0.45];
}

link_message(integer sender_num, integer num, string message, key id)
// i tend to use 1 parent listener script for many functions
// so the info is fed to this script tru linked messages
{
number = message;
if ((integer)number <=999999) sort();
else llWhisper(0,"number too large");
}
}


course nowdays i would take the time to make shure the grid is on square with eachoter and use a math function to replace the redundent list enterys
Greg Hauptmann
Registered User
Join date: 30 Oct 2005
Posts: 283
02-13-2006 04:23
Thanks Osgeld,

Is the texture offset mechanism the only one that's really available to implement a countdown timer display though? (i.e. an in this case its really just up to optimising the approach as best possible, per your excellent ideas/advice)

There's no means available? The only that come to mind for me based on my knowledge to date - comments?:
  1. the llSetText() approach: I'm assuming this won't provide a real display/scoreboard type effect (however I should play more with this I guess)
  2. heads up display: doesn't really adhere to my requirements, and I haven't played with HUDs yet, but perhaps handing a HUD to each player so that they can see a countdown timer themselves for the game might be good?
  3. <others???>
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
02-13-2006 04:41
I was building a game system last night that has a countdown timer, and I just used SetText on the server prim (also to display scores). I'm pretty sure it's the most efficient way to display dynamically changing text. On the other hand, mine was a prototype, and SetText may not work out visually with your particular design. It's also not visible from a very long way away.

At the moment the players don't have a timer, but their guns - it's a paintball type thing - listen for server messages and let the players know. It's probably best if they have a minute count, and then a thirty seconds warning, then a ten-nine-eight... countdown and then "GAME OVER".

Could have an initial shout that synced the game objects, and have them keep the time themselves, as well. That would run into problems if players removed or reattached their guns though.

For player info display I use a system I've developed myself that either feeds to a generic HUD if the player has one attached, or sets float text if they don't. If you're interested in that take a look at my home area (it's in my profile or on my blog, can't remember it off-hand) - it's the "Oghma HUD Info System", there's a notecard and free full-mod scripts and HUD device for it.
Greg Hauptmann
Registered User
Join date: 30 Oct 2005
Posts: 283
02-14-2006 00:22
tks Ordinal - sounds like the options for countdown timer are truely
- texture setting (e.g. xytext)
- llSetText and
- HUD
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
02-14-2006 00:31
It should be noted that changing the hover text of an object forces a full update where as offsetting a texture only causes a terse update ... depending on how often/how many objects this is happening to the texture offset method may be a beteter option.
Jopsy Pendragon
Perpetual Outsider
Join date: 15 Jan 2004
Posts: 1,906
02-14-2006 17:51
You could always use llAnimateTexture and a texture mapped out with all the digits to add a pointless but cool looking 1/10th of a second digit to the display as well. :)
_____________________
* The Particle Laboratory * - One of SecondLife's Oldest Learning Resources.
Free particle, control and targetting scripts. Numerous in-depth visual demonstrations, and multiple sandbox areas.
-
Stop by and try out Jopsy's new "Porgan 1800" an advanced steampunk styled 'particle organ' and the new particle texture store!