Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to set the step size in a for Loop?

Rock Ryder
Registered User
Join date: 6 Oct 2006
Posts: 384
09-20-2007 10:30
Hi guys,

Can anyone tell me how to convert a for loop like -

for x = 0 to 40 step 4

into lsl?

The wiki only gives single increment examples, like -

for (x = 0; x <= 40; x++)

Much obliged

Rock
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
09-20-2007 10:33
From: Rock Ryder
Hi guys,

Can anyone tell me how to convert a for loop like -

for x = 0 to 40 step 4

into lsl?

The wiki only gives single increment examples, like -

for (x = 0; x <= 40; x++)

Much obliged

Rock



You should be able to just change the x++ to x=x+whatever.

++ is the LSL shortcut for saying x=x+1
Lyn Mimistrobell
(waiting)
Join date: 11 Jan 2007
Posts: 179
09-20-2007 11:21
yes, so litterally:

for (x = 0; x <= 40; x += 4)
{
}
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
09-20-2007 11:26
From: Tiarnalalon Sismondi
You should be able to just change the x++ to x=x+whatever.

++ is the LSL shortcut for saying x=x+1

And += means "add to yourself" so "x += 4" means "add 4 to x".

See also -=, *=, /= and maybe others, too.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left