Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Function returning hole size of torus?

Olympia Rebus
Muse of Chaos
Join date: 22 Feb 2004
Posts: 1,831
06-01-2005 09:58
Hi,
I'm working on a script that needs to include the current hole size of a torus in its calculations. I know llGetPrimParamerers (or something similar) returns the hole size, but it comes with a bunch of other parameters too and I don't know how to isolate the hole size. Any ideas?

Thanks in advance.

p.s. would something like
From: someone
llGetPrimitiveParams([HOLE_SIZE]);

return what I'm looking for?
_____________________
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
06-01-2005 11:03
PRIM_TYPE returns a long list of info, including hole size for the torus. You can read about this on the wiki page for llSetPrimitiveParams 'cause the details aren't on the page for llGetPrimitiveParams . :)
_____________________
Chandra Page
Build! Code. Sleep?
Join date: 7 Oct 2004
Posts: 360
06-01-2005 12:09
llGetPrimitiveParams produces a big honkin' list of of output, primarily because the big honkin' list is what llSetPrimitiveParams takes as an argument. Just grabbing a single value out of the reams of output llGetPrimitiveParams produces isn't difficult, but it is annoying. Drop this script into the torus:

CODE
vector GetHoleSize()
{
list params;
integer primType;
vector holeSize = ZERO_VECTOR;


params = llGetPrimitiveParams([PRIM_TYPE]);
primType = llList2Integer(params, 0);

if (primType == PRIM_TYPE_TORUS ||
primType == PRIM_TYPE_TUBE ||
primType == PRIM_TYPE_RING)
{
holeSize = llList2Vector(params, 5);
}
else
{
llOwnerSay("Primitive type does not have a hole size.");
}

return holeSize;
}

default
{
touch_start(integer total_number)
{
llSay(0, "Hole size: " + (string)GetHoleSize());
}
}


Touching the primitive will cause it to report its hole size. Hole size is stored as a vector; the third vector parameter is not used and will always be 0.0.
_____________________
Come visit the In Effect main store and café
Drawbridge (160, 81)
Particle effects, fashion, accessories, and coffee!
On the Web at SL Exchange and SL Boutique
Olympia Rebus
Muse of Chaos
Join date: 22 Feb 2004
Posts: 1,831
06-01-2005 12:13
Ooooh, very nice!
You even added a part to deal with the object being a prim without a hole. Sweet!
:D
From: Chandra Page
llGetPrimitiveParams produces a big honkin' list of of output, primarily because the big honkin' list is what llSetPrimitiveParams takes as an argument. Just grabbing a single value out of the reams of output llGetPrimitiveParams produces isn't difficult, but it is annoying. Drop this script into the torus:

CODE
vector GetHoleSize()
{
list params;
integer primType;
vector holeSize = ZERO_VECTOR;


params = llGetPrimitiveParams([PRIM_TYPE]);
primType = llList2Integer(params, 0);

if (primType == PRIM_TYPE_TORUS ||
primType == PRIM_TYPE_TUBE ||
primType == PRIM_TYPE_RING)
{
holeSize = llList2Vector(params, 5);
}
else
{
llOwnerSay("Primitive type does not have a hole size.");
}

return holeSize;
}

default
{
touch_start(integer total_number)
{
llSay(0, "Hole size: " + (string)GetHoleSize());
}
}


Touching the primitive will cause it to report its hole size. Hole size is stored as a vector; the third vector parameter is not used and will always be 0.0.
_____________________
Stinky Queso
Second Life Resident
Join date: 29 Nov 2004
Posts: 53
06-01-2005 21:40
If for building purposes you wanted to find the actual size of the hole in meters, you could always do something like:

holesize/10 * primsizeX;
holesize/10 * primsizeY;

err, unless holesize returns something like a float between 0 and 1, which is most likely. then you would multiply by ten. ok, this isnt terribly useful but i had this idea, and here it is.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
06-01-2005 23:21
FYI holesize and topsize are the same paramater.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Olympia Rebus
Muse of Chaos
Join date: 22 Feb 2004
Posts: 1,831
06-02-2005 08:10
From: Stinky Queso
If for building purposes you wanted to find the actual size of the hole in meters, you could always do something like:

holesize/10 * primsizeX;
holesize/10 * primsizeY;

err, unless holesize returns something like a float between 0 and 1, which is most likely. then you would multiply by ten. ok, this isnt terribly useful but i had this idea, and here it is.


Thanks Stinky,
I can't wait to log in tonight and try it that out :D

Thanks to Strife for the tip about topsize too
_____________________