Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Performance and referencing

DazL Dumouriez
Registered User
Join date: 11 Aug 2006
Posts: 6
08-28-2006 06:19
Hello,

Im kind of new to scripting in SL, although I have lots of experience in ASP and VB.

After my first few scripts I have a few issues I hope someone can enlighten me on=)

1) Is there a way to refer to another object without listeners. For example if I have 3 objects, can I rescale object 2 and object 3 from a script in object 1? Or do I have to use a listener in object 2 and object 3 and do the rescaling in those objects?

2) I made a very simple rescaling script. It was resizing an object in 10 steps from 2m to 0m. I was dissapointed by the result, because the loop took multiple seconds to run. (Used 10x setScale to resize it). What is causing this slow performance? Is this server or client side? I know other ppl see the effect of my actions also, but I dont know if the script runs local for everybody who sees the object, or is running server side.

3) Another thing I noticed was that if I put 2 resizing scripts into objects, which were triggered by a listener, they didnt perform in the same way. One script would run faster than the other one, although they are exact the same... Do I have to build in all kind of checks to keep scripts like these running at the same pace, or am I missing something?

Thanx in advance=)
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
08-28-2006 06:44
From: DazL Dumouriez
2) I made a very simple rescaling script. It was resizing an object in 10 steps from 2m to 0m. I was dissapointed by the result, because the loop took multiple seconds to run. (Used 10x setScale to resize it). What is causing this slow performance? Is this server or client side?

There's automatic delay built in most functions which manipulate prim attributes, but curiously enough not in llSetScale() so this sort of delay is puzzling
CODE

default {

touch_start(integer total_number) {

vector scale = llGetScale();
integer idx;
for( idx = 0; idx < 10; ++idx ) {

scale += <0.1, 0.1, 0.1>;
llSetScale( scale );
}
for( idx = 0; idx < 10; ++idx ) {

scale -= <0.1, 0.1, 0.1>;
llSetScale( scale );
}
}
}

basic scaling script, gave it a try and it seemed smooth to me... it could be the sim you were running your scripts was severely lagged, or something. Hard to say without seeing the code o.O;
DazL Dumouriez
Registered User
Join date: 11 Aug 2006
Posts: 6
08-28-2006 06:55
Im repositioning the objects also. Does setPos have a build in delay?

Any dev ever explained why there is a build in delay in some functions? I cant think of any use for build in delay... Id rather control all delays myself if possible.
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
08-28-2006 07:07
From: DazL Dumouriez
Im repositioning the objects also. Does setPos have a build in delay?

Any dev ever explained why there is a build in delay in some functions? I cant think of any use for build in delay... Id rather control all delays myself if possible.

Yes, llSetPos() pauses script execution for 0.2 sec after each call.

handy table here: http://secondlife.com/badgeo/wakka.php?wakka=ScriptDelay

dunno about dev explanation, but common reason would be to put the throttle on amount of sim state updates caused by scripts, to give the sim some breathing space, and the players in sim a chance actually receive them and see on their screens.

Of course, since people go around it by using multiple linked scripts rather than one with its delays, the end effect on sim performance is probably opposite, if anything o.O;
DazL Dumouriez
Registered User
Join date: 11 Aug 2006
Posts: 6
08-28-2006 08:16
From: Joannah Cramer
Yes, llSetPos() pauses script execution for 0.2 sec after each call.

handy table here: http://secondlife.com/badgeo/wakka.php?wakka=ScriptDelay

dunno about dev explanation, but common reason would be to put the throttle on amount of sim state updates caused by scripts, to give the sim some breathing space, and the players in sim a chance actually receive them and see on their screens.

Of course, since people go around it by using multiple linked scripts rather than one with its delays, the end effect on sim performance is probably opposite, if anything o.O;


Ok thanks that answers my question about the delay=)

If I want to rezise a object, but keep x pos static, is there a way I can do this without changing the position after each resize?

For example I made a door with some bars (cilinders). On touch I made them move into the doorpost and resized them so they didnt go through the post. I had to move them, because only resizing them resulted on the bars hanging in the middle of the door, instead of moving in the doorpost.

Anybody knows a workaround without changing position?
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
08-28-2006 08:55
There isn't one, setting scale doesn't include a "which end" to add the extra to, so it expands both ways, hence the need to reposition.

However, you can use llSetPrimitiveParams to set scale and position in a single call so it happens together.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
08-29-2006 00:54
Prims are always centered on the coordinates.
That is why you have to change the position for your door bars.
No way around it.