|
Joshua Philgarlic
SLinside.com
Join date: 29 Jan 2007
Posts: 143
|
06-27-2007 06:24
I know that llGetPrimitiveParams can be used to determine certain Prim parameters. I'm working on a script that should react in different ways depending on which kind of Prim it is attached to (box, cylinder etc.). Now, my problem is: I don't understand the description of llGetPrimitiveParams at all! Please, is there somebody who can explain it for people who don't have a doctoral level in computer science?
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
06-27-2007 06:49
// This only asks for the Prim Type.. but we could ask for other parameters if we wanted. list primParams = llGetPrimitiveParams([PRIM_TYPE]);
switch (llList2Integer(primParams, 0)) { case PRIM_TYPE_BOX: llOwnerSay("I'm a Box!"); break; case PRIM_TYPE_CYLINDER: llOwnerSay("I'm a Cylinder!"); break; case PRIM_TYPE_PRISM: llOwnerSay("I'm a Prism!"); break; case PRIM_TYPE_RING: llOwnerSay("I'm a Ring!"); break; case PRIM_TYPE_SPHERE: llOwnerSay("I'm a Sphere!"); break; case PRIM_TYPE_TORUS: llOwnerSay("I'm a Torus!"); break; case PRIM_TYPE_TUBE: llOwnerSay("I'm a Tube!"); break; }
|
|
Joshua Philgarlic
SLinside.com
Join date: 29 Jan 2007
Posts: 143
|
06-27-2007 08:35
Hi Milambus, Thanks for your help. I think you've mixed some PHP-Code with your LSL script, isn't it? Anyway, you gave me enough information to create my own script: default { changed(integer total_number) { list primParams = llGetPrimitiveParams([PRIM_TYPE]); // if (llList2Integer(primParams,0)==PRIM_TYPE_BOX) { llOwnerSay("Box"  ; } if (llList2Integer(primParams,0)==PRIM_TYPE_CYLINDER) { llOwnerSay("Cylinder"  ; } if (llList2Integer(primParams,0)==PRIM_TYPE_PRISM) { llOwnerSay("Prism"  ; } if (llList2Integer(primParams,0)==PRIM_TYPE_SPHERE) { llOwnerSay("Sphere"  ; } if (llList2Integer(primParams,0)==PRIM_TYPE_TORUS) { llOwnerSay("Torus"  ; } if (llList2Integer(primParams,0)==PRIM_TYPE_TUBE) { llOwnerSay("Tube"  ; } if (llList2Integer(primParams,0)==PRIM_TYPE_RING) { llOwnerSay("Ring"  ; } if (llList2Integer(primParams,0)==PRIM_TYPE_SCULPT) { llOwnerSay("Sculpt"  ; } //} } }
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
06-27-2007 08:48
Yea, most other languages support a switch statement and I'm at working in the middle of some ActionScript, so I forgot that LSL doesn't support it.
For your code, switch those if statements, to Else ifs.
Right now, when the code executes it has to evaluate every one of those If statements. By using Else If statements, it only has to evaluate until it finds the one that is true.
You'll probably never see a difference in just one script, but the wasted CPU cycles add up when there are tens of thousands of scripts running on a Sim.
|