lfnetwork.com mark read register faq members calendar

Thread: For Loops
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 06-06-2013, 07:36 AM   #1
Vindikorr
Rookie
 
Vindikorr's Avatar
 
Join Date: Apr 2013
Posts: 123
Current Game: TOR
For Loops

I'm getting a syntax error when trying to use for loops, ie:

Code:
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.


My WIP: The Liberation of Manaan

Quote:
Originally Posted by Totalbiscuit
Can tell it's been a busy day, 121 Chrome tabs open
28.04428% on the geek test

Bile Beans keep you healthy, bright-eyed and slim
Vindikorr is offline   you may: quote & reply,
Old 06-06-2013, 01:31 PM   #2
Fair Strides 2
Witty Programmer
 
Fair Strides 2's Avatar
 
Join Date: Jan 2012
Location: Oregon, United States
Posts: 584
Current Game: Master of Orion 2
Helpful! 
Quote:
Originally Posted by Vindikorr View Post
I'm getting a syntax error when trying to use for loops, ie:

Code:
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:

Code:
void main()
{
    int i;

    for(i = 0; i < 5; i++) {
    //do stuff
    }
}


All of my mods are available on Deadlystream.

Always remember modders: "Quality= Effort*Time"

KSE 3.3.4 is LIVE!!! Check it out here.

Check out WalkSwitch, the Walkmesh-changing tool!
Fair Strides 2 is offline   you may: quote & reply,
Old 06-06-2013, 02:31 PM   #3
Vindikorr
Rookie
 
Vindikorr's Avatar
 
Join Date: Apr 2013
Posts: 123
Current Game: TOR
Worked perfectly, thanks.


My WIP: The Liberation of Manaan

Quote:
Originally Posted by Totalbiscuit
Can tell it's been a busy day, 121 Chrome tabs open
28.04428% on the geek test

Bile Beans keep you healthy, bright-eyed and slim
Vindikorr is offline   you may: quote & reply,
Old 06-08-2013, 07:33 AM   #4
VarsityPuppet
Master of Puppets
 
VarsityPuppet's Avatar
 
Join Date: May 2009
Location: MN
Posts: 1,253
Current Game: Chrono Trigger
Contest winner - Modding Forum Veteran Veteran Modder Helpful! 
Also, a side note, I don't think I've ever gotten foreach loops to work either

VarsityPuppet is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > For Loops

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:21 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.