Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Listeners or Timers - Lowest Lag solution for Multiple Object rotation?

Geoff Althouse
Registered User
Join date: 26 Sep 2006
Posts: 6
06-07-2007 16:12
Hello to Everyone :)

This is my first post to the Forums, and I hope someone can help me out:

I'm modding a wind farm to rotate the turbine heads into the wind, and I have 2 ways of doing it, but wanted to get your thoughts on the lowest lag implementation:


Option 1: A timer script in each turbine head, that checks the wind direction every x seconds (say 60 seconds) and adjusts the rotation if it has changed since the last check (e.g. was NW now E)

Option 2: Have a central controller monitoring the wind on the timer, and the turbines listen for updates. When there is a change, the controller sends a message (llRegionSay ?) with the new co-ords.

I have the core code for making the rotation changes (plus the code to vary the speed of the rotations based on the wind speed - Thank Nand Nerd for that :)

There will be between 15 and 20 turbines, and I may also add whichever solution into some flags (to improve the 'flutter' of the flexi-prim).

What would be the better of the 2 options in terms of reduced lag? any thoughts or better options gratefully received :)

Kind regards,

Geoff
Jake Trenchard
Registered User
Join date: 31 May 2007
Posts: 104
06-07-2007 16:19
Listening appears to be event driven, so nothing will be processed unless something is said on the channel, so less usage overall. On the other hand, they will all trigger at once with the listen, so you may want your first action on hearing something to be sleep a random period of time ....

I'm assuming here that it works as the documentation seems to indicate, I've never tested for lag.
Geoff Althouse
Registered User
Join date: 26 Sep 2006
Posts: 6
06-07-2007 19:56
Great stuff, thanks Jake :)

Any others with advice welcomed :)

On a related note - the WindSpeed and Rotation vectors returned are *very* specific (for example, the speed might be 5.207408 somethings (metres per second?)

How would I go about reducing the figure to 2 decimal places?

Also how about reducing it to a single digit (rounded up or down) ?

Many thanks in advance,

Geoff
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
06-07-2007 22:35
llRound
llFloor (round always down)
llCeling(round always up)
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
06-07-2007 23:59
Make a function to which you pass a float to return a string.

In your function:
Multiply the float by a 100 first to give you two dp places.
Then llRound to give you an integer (i).
Divide (i / 100) and cast to string for lhs of answer
Modulo (i % 100) and cast to string for rhs of answer
Then return lhs + "." + rhs

Probably heaps of better ways.

Edit: sorry did not see need for no dp, so use Osgeld's suggestions.
Geoff Althouse
Registered User
Join date: 26 Sep 2006
Posts: 6
06-08-2007 01:21
Thanks peeps :)

Just whizzed the 101 and 'Crash Course' on the RPGstats WiKi - should have done that earlier!

All makes a lot more sense now - and I have some nice new tricks to simplify the code I wrote :)

Thanks for the help,

Geoff