Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Which is the better method of scripting for this small project

Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
04-13-2007 08:47
I'm working on a simple clock that accurately displays the time with analogue hands and I have come across two ways to accomplish this.

Single Script
a single script polls for the current time every second and then uses llSetLinkPrimitiveParams to adjust the angles of the various clock hands appropriately.

Multiple Scripts
Each individual hand has it's own script and polls for the time at various intervals to set their positions accordingly. ex; hour hand polls for the time every 5 minutes, minutes hand every 5 seconds, and second hand every second.


This is purely an exercise to get me reaquainted with manipulating prims via script, and try out various new functions that have been introduced since I was in SL last. Causing lag with this script isn't an issue (I know that the single script is supperior in this regard), but I'm wondering if functionally the two approaches could have advantages/disadvantages for other reasons.
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Ged Larsen
thwarted by quaternions
Join date: 4 Dec 2006
Posts: 294
04-13-2007 08:57
From: Senuka Harbinger
I'm working on a simple clock that accurately displays the time with analogue hands and I have come across two ways to accomplish this.

Single Script
a single script polls for the current time every second and then uses llSetLinkPrimitiveParams to adjust the angles of the various clock hands appropriately.

Multiple Scripts
Each individual hand has it's own script and polls for the time at various intervals to set their positions accordingly. ex; hour hand polls for the time every 5 minutes, minutes hand every 5 seconds, and second hand every second.


This is purely an exercise to get me reaquainted with manipulating prims via script, and try out various new functions that have been introduced since I was in SL last. Causing lag with this script isn't an issue (I know that the single script is supperior in this regard), but I'm wondering if functionally the two approaches could have advantages/disadvantages for other reasons.


I did this a few weeks ago, just for fun, before the llSetLinkPrimitiveParams was out there. I think either way would be fine, but I'd recommend using your second hand as a llTargetOmega, to reduce lag, and to give smoother motion.

It won't be "accurate" (i.e., every client will see the second hand differently), but I doubt you need precision to the "second" anyhow.

If you care, my solution was to use a single script, duplicated in each of the 3 hand prims, linked to a root prim clock face. The hand prims would have either "hour" "minute" or "second" in the description, as well as additional information that defined the proper axis of rotation for that particular hand, and the script would read the information from the hands' description and act accordingly. The script was touch-activated to "set" the time, in case you didn't want the default of PST / LST. It was a fun exercise, although not terribly practical.
_____________________
- LoopRez, flexi prim skirt generating tool
- LinkRez, a necklace chain generator