Author Topic: [Engine] Possible to add "foreach"?  (Read 899 times)

Is it possible to add foreach into the engine? It would make things easier.

Not really because of the way arrays work; %test[1] simply being an easy way to write %test_1 instead of %test being a formal collection
Probably the best you can do is a foreach function that takes the array name and a function to call on each member, internally using a while loop that starts searching and index 0 and continues until finding an element $= "". There's obvious disadvantages to that though

newer versions of torquescript have a foreach statement

i think it's mostly for groups though since obv arrays aren't actually arrays, but that's still useful

Shameless self-advertisement: LeverScript has it:

for client in ClientGroup.iter() {
    client.chatMessage("Hello");
}

Shameless self-advertisement: LeverScript has it:

for client in ClientGroup.iter() {
    client.chatMessage("Hello");
}

How can I get this to happen if possible?



http://github.com/portify/lever
holy stuff
how come nobody ever told me this existed
bookmarked the hell out of this