Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Q: how do i link a wait to the frame rate.

Jonathan Morris
Registered User
Join date: 5 Jan 2006
Posts: 66
02-12-2006 23:57
I'm new to SL scripting.
I want to build a motion script.
Idealy this script would calculate object position once for each frame the server is showing.
The frame rate should be about 45 per second, giving a wait of about 0.022s.
If I use a 0.022 wait, there will be flicker, as once in a while I will miss a frame or double calculate in a single frame.
Is there a " frame start " event handler.

I'm adapting old programing skills to a new language ( my first program was read from punched cards ! ), having fun with what SL can do. congratulations Linden.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
02-13-2006 00:04
thats what i did and still do im a basic type of guy, back before the sims were locked at 45fps it would be hard to do. as it is now you are correct, but your not taking in account for time dialation which is still dynamic... i dont really have any helpfull suggestions but to eyeball it till its right

you probally will get a better awnser tommarow :)
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
02-13-2006 00:04
I think this is probably impossible - scripts all run server side, whereas the displayed frame rate is dependent on the client. You may have to settle for a slower update rate (a very fast timer will be bad for lag too, if it doesn't just start backing up a queue).
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
02-13-2006 01:04
If you absolutely need the code to run for every frame, you might need an infinite loop, because the minimum time llSleep will actually wait is about 50 ms (> 2 frames).

I think there are a number of things to try out to explore how SL's VM runs the scripts, for example:
- is there really a delay for each iteration of loops (do/while, for(), jump @, etc) ??
- is it really a delay or a wait for the next server frame ?
- if there isn't such delay/wait, can a very fast timer do it, or would it not be synced with the server framerate ?
- is the minimum delay really ~50ms ?

[Edit]
According to these pages:
http://secondlife.com/badgeo/wakka.php?wakka=llMinEventDelay
http://secondlife.com/badgeo/wakka.php?wakka=scriptdelay
The minimum delay between two events is by default 0.1s and can only be reduced to 0.05s, so you'd need an infinite loop.

[Edit]
Seifert, it seems that timer() doesn't make a queue of events if it runs in more time than its set delay :)
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
02-13-2006 01:20
From: Jesrad Seraph
Seifert, it seems that timer() doesn't make a queue of events if it runs in more time than its set delay :)
It just loses that event? I guess that makes sense... don't be doing anything mission critical that often then.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
02-13-2006 01:25
According to the Wiki's testing report, the next timer event just runs just after the current one, it simply is delayed a bit (or a lot if it took long to complete).
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
02-13-2006 02:16
Let me ask the stupid question: Jonathan, are you aware of physics and the kinetic functions? If you are, and there is a valid reason for using "faked motion" (as there often is) - then cool, disregard this.
Otherwise, you might be able to make your life (and the sim's) much easier.
Jonathan Morris
Registered User
Join date: 5 Jan 2006
Posts: 66
02-13-2006 04:58
From: Ben Bacon
Let me ask the stupid question: Jonathan, are you aware of physics and the kinetic functions? If you are, and there is a valid reason for using "faked motion" (as there often is) - then cool, disregard this.
Otherwise, you might be able to make your life (and the sim's) much easier.


Question is NOT stupid, I have found :
impulse ( not shure if this is kinetik or phisical ( mass sensitive ))
move to target or SetPos, is the one I wanted to use once a frame to give motion. alowing me to write my own damping etc.
The Rot commands need more explanation than the linden guide gives ( need to play :-)),
but Set rot seems useful.
basicaly I want to write vehicle driveing scripts, where I have full control of the object.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-13-2006 06:59
From: Jonathan Morris
I want to write vehicle driveing scripts, where I have full control of the object.
I don't believe LSL is fast enough to do this at physics frame rates. There's no real-time guarantees.