Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

scale prims

Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
04-04-2009 12:15
default {
link_message(integer sender_num, integer num, string str, key id) {
float scale; // size factor
list primparams;

scale = (float)str;

primparams = [];

primparams += [PRIM_SIZE, llGetScale() * scale]; // resize

if (llGetLinkNumber() > 1) { // only move if we're not the root object
primparams += [PRIM_POSITION, llGetLocalPos() * scale]; // reposition
}

llSetPrimitiveParams(primparams);
}
}

Ok peps I found the above code in the lsl wiki. Kinda old school on how they want to you to give the scale. For the bast few days I will have been trying to come up with a way where I can send scale presets on a linked message But thats they easy part. I think what I want to happen needs to use the lsl math commands. What I want to do is scale in steps of like if picked

+ 0.010
++ 0.050
+++ 0.100

- 0.010
-- 0.050
--- 0.100

with the one I see in the lsl wiki if I send 0.010 it will set the scale of prims to 0.010 not scaleing them step by step. Any ideas on how I would about doing a step by step set up?
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
04-05-2009 02:52
hmmm...

default {
link_message(integer sender, integer num, string msg, key id)
{
float change = (float)msg;
vector scale = llGetScale();
list params = [PRIM_SIZE, scale + <change, change, change>];

if (llGetLinkNumber() > 1)
{
// Memory isn't cheap for LSL. Recycle variables!
scale = <;(scale.x + change) / scale.x, (scale.y + change) / scale.y, (scale.z + change) / scale.z>;
vector pos = llGetLocalPos();
params += [PRIM_POSITION, <pos.x * scale.x, pos.y * scale.y, pos.z * scale.z];
}

llSetPrimitiveParams(params);
}
}

In English: The script expects a positive/negative value in the link message. It add this value to the 3 dimensions of the prim and, when required, it calculates the scale factor on each axis to re-position the prim.

It should work but, because of the rounding error server which handles floats in SL, I wouldn't advise to use very small values. :P