Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Setting properties with string instead of intiger?

Nickolus Lufbery
Registered User
Join date: 14 Oct 2006
Posts: 25
07-05-2008 19:49
I was wanting to make the light around an object random, but the only random scripts linden provides are ones that output random numbers in to string instead of intigers.

I was wondering if there's a way to convert a string in to an intiger...


llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,
<1.0,1.0,1.0>,LIGHTVALUE,10.0,0.6 ]);


if LIGHTVALUE is an intiger it works fine... but if it's a string it doesn't. Even if the string is a complately valid value.
Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
07-05-2008 19:55
Typecast it?

http://lslwiki.net/lslwiki/wakka.php?wakka=typecast
_____________________
There are no stupid questions, just stupid people.
Monica Balut
Beam-Me
Join date: 18 Feb 2007
Posts: 311
07-05-2008 19:59
Not sure what you're trying to do, but why not use (integer) llFrand(mag )?
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
07-06-2008 02:58
Might be worth reviewing the Wiki for a description of llFrand:

llFrand returns a float, which is convenient in this case as the light intensity parameter you're trying to set is also a float. The valid values for the light intensity parameter range from 0.0 to 1.0, so:

llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1.0,1.0,1.0>, llFrand(1.0), 10.0, 0.6]);

...would give you random values of 0.0 to 0.999999


Using an integer here would actually be an odd choice unless you wanted the light intensity to be either 0 (off) or 1 (on):

llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1.0,1.0,1.0>, (integer)llFrand(2.0), 10.0, 0.6]);

...which would only give values of 0 and 1.
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
07-06-2008 03:04
if LIGHTVALUE is a string, this trick should get your script working.

llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,
<1.0,1.0,1.0>,(integer)LIGHTVALUE,10.0,0.6 ]);

now.. if LIGHTVALUE is a string, and the string is "0" or "1" that will work. it's NOT going to work if the string is "TRUE" or "FALSE" or "ON" or "OFF"
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura