|
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.htmland 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 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
|
|
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.
|