Vindikorr Posted June 6, 2013 Share Posted June 6, 2013 I'm getting a syntax error when trying to use for loops, ie: for(int i = 0; i < 5; i++) { //do stuff } This should work should it not? Do they work differently in nwscript for some reason, or are they not supported at all. If so, what other ways could I iterate a command through multiple objects? I don't want to assign it to each object individually because it is messy code, and if there's one thing I hate in this world it's messy code. Link to comment Share on other sites More sharing options...
Fair Strides 2 Posted June 6, 2013 Share Posted June 6, 2013 I'm getting a syntax error when trying to use for loops, ie: for(int i = 0; i < 5; i++) { //do stuff } This should work should it not? Do they work differently in nwscript for some reason, or are they not supported at all. If so, what other ways could I iterate a command through multiple objects? I don't want to assign it to each object individually because it is messy code, and if there's one thing I hate in this world it's messy code. Your only mistake is a very small one. In nwscript, you can't declare an integer in the for loop itself. It has to be declared before. So your code should work if put like this: void main() { int i; for(i = 0; i < 5; i++) { //do stuff } } Link to comment Share on other sites More sharing options...
Vindikorr Posted June 6, 2013 Author Share Posted June 6, 2013 Worked perfectly, thanks. Link to comment Share on other sites More sharing options...
VarsityPuppet Posted June 8, 2013 Share Posted June 8, 2013 Also, a side note, I don't think I've ever gotten foreach loops to work either Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.