Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Don't understand script grammar

Zerir Eldrich
Registered User
Join date: 13 Mar 2006
Posts: 3
03-13-2006 11:51
I found this script:

llParticleSystem([
PSYS_PART_FLAGS, PSYS_PART_WIND_MASK
| PSYS_PART_EMISSIVE_MASK,
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE,
PSYS_PART_START_COLOR, <1,0,0>]);

But it doesn't seem to make sense. There's only one OR (pipe), yet according to the ParticleSystem wiki, almost all of those are independant flags. I'm guessing some of the commas delimit arguments, and some seperate the flags themselves.
How would I add PSYS_PART_INTERP_COLOR_MASK to that mess up there?
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
03-13-2006 12:59
It's a list of arguments.

llParticleSystem([
PSYS_PART_FLAGS, PSYS_PART_WIND_MASK | PSYS_PART_EMISSIVE_MASK,
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE,
PSYS_PART_START_COLOR, <1,0,0> ])

The bold show the commands, the italics the paramters. A few LSL commands work like this; they take a single list as an argument, and parse it. If the function sees PSYS_PART_FLAGS then the next list item is the flags, and you can add extra flags to it.

If you want to play with particles I suggest looking at http://secondlife.com/badgeo/wakka.php?wakka=LibraryKeknehvParticles which provideds a nice layout for easy editing.
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
03-13-2006 13:04
Thank you! I was looking for that too!
Zerir Eldrich
Registered User
Join date: 13 Mar 2006
Posts: 3
03-13-2006 14:17
From: Nepenthes Ixchel
It's a list of arguments. ...


Thanks for the example, Nepenthes, I'll check out the particle tutorial too. My confusion stems from the fact that commands and arguments within them are all delimited by the same character. With a little more practice I'm sure I'll be able to make sense of this rather unusual syntax.
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
03-13-2006 15:01
From: Zerir Eldrich
Thanks for the example, Nepenthes, I'll check out the particle tutorial too. My confusion stems from the fact that commands and arguments within them are all delimited by the same character. With a little more practice I'm sure I'll be able to make sense of this rather unusual syntax.


Consistency is for people who don't like a challenge!

Working around the flaws in LSL is part of being a scripter, just as working around the flaws in the UV maps are part of being a clothing designer, working around the limitations of the building system is part of being a builder, and working around lag is part of playing Second Life.
Zerir Eldrich
Registered User
Join date: 13 Mar 2006
Posts: 3
03-13-2006 15:44
Hrm, but inconsistent language syntax is easily fixable, and not dependant on environmental conditions (server traffic) like lag. I'll end by saying it's very strange that as successful as Linden has been, they haven't yet fixed these throbbing flaws.
paulie Femto
Into the dark
Join date: 13 Sep 2003
Posts: 1,098
a fix would bork existing content
03-13-2006 15:48
:)

and, that's how list items are seperated. by commas. see how the start and end of the list are specified with [ and ]? that's how you know you're dealing with a list. lists can contain any type of argument between the commas: strings, floats, integers, vectors, etc. the list doesnt care. it's up to the function that interprets the list (or us abused coders) to make sense of the list. a list is just a big bucket o stuff. lol.

after saying that, I agree that it looks kinda strange that the flags are ORed with |. i guess the flags are stored as bitfields internally, so ORing makes sense, but it does look weird in the middle of a list.

oh yeah. lists are what passes for arrays in LSL. you can call elements of a list by their index. but only 1 dimensionally. unless you get very tricky. :)

and yes, i'm allergic to caps. lol.
_____________________
REUTERS on SL: "Thirty-five thousand people wearing their psyches on the outside and all the attendant unfettered freakishness that brings."
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
03-13-2006 16:10
From: Zerir Eldrich
Hrm, but inconsistent language syntax is easily fixable, and not dependant on environmental conditions (server traffic) like lag. I'll end by saying it's very strange that as successful as Linden has been, they haven't yet fixed these throbbing flaws.


What do you mean, "throbbing flaws"? This is simply list syntax-- would you rather they had a function call with 50 parameters?
paulie Femto
Into the dark
Join date: 13 Sep 2003
Posts: 1,098
throbbing flaws
03-13-2006 16:12
i like that terminology. but then i'm weird. and i do see his point about the confusing syntax. the syntax doesn't (imho) make enough distinction between list parameters and list values. the two are just thrown together in a jumble, since that's how lists work. jumbly.

it feels like the particle system functionality was shoehorned into a list because that's the only data structure which was available to hold it and readability be damned.

there must have been a better, less confusing, way to implement it. but, it's too late, now.

oh, and Zerir, if you thinks lists are fun... wait till you try and read from a notecard. giggle.

to be fair, we are supposed to be getting MONO support rsn (real soon now.) MONO should (theo-rhetorically) allow us to code in languages other than LSL. time will tell.
_____________________
REUTERS on SL: "Thirty-five thousand people wearing their psyches on the outside and all the attendant unfettered freakishness that brings."