![]() |
Explaination of for
Well, it seemed to me that some people are very unfamiliar with for.
This is what for actually is: NPC Code: So, for works like this: Quote:
NPC Code: if you don't want an uber-lagged level with an infinite for-loop. So, once more: Quote:
NPC Code: for example. I hope you see all possibilities of i. Here's a nice example: NPC Code: |
Re: Explaination of for
Quote:
|
I'm not so familiar with //#CLIENTSIDE and serverside, does anybody know any good tutorial?
|
Your 'nice' example is quite the opposite. If you're attempting to teach people then you should indent, and you shouldn't encourage them to do icky things like putting sleeps in loops.
|
1 Attachment(s)
But Kaimetsu, if i were to create a NPC that would make the level slightly darker every 0.05 seconds, then wouldn't a for loop with sleep be the best solution?
Oh yeah, here's some strange stuff i did with for loops and polygons o.o |
use a timeout instead
|
Yes, but what if i'd wanted to repeat my action? In my "nice" example above, it'd repeat without trouble. How would it work with timeout? You can save some trouble with a sleep for loop. And i don't really see what's wrong with sleep :/
NPC Code: |
Quote:
Quote:
|
Quote:
|
Stupid advanced scripting :/..
|
Quote:
It works like this: for(a;b;c){ stuff (optional); } a. The variable, and what you want it to start as (for example a = 0) b. The condition that has to happen when you want c to happen. c. The change to a variable that you want to happen (NOTE: Doesn't have to be the same variable as a, but be careful not to infinite for loop. In other words, where the optional place is you have to make it catch the variable at some point and stop the for loop. Otherwise you will crash your graal). |
Quote:
But, Kai, can you please explain me what is wrong with sleep? |
Quote:
I'll probably add a mention to KSI-GS at some point, you can read it then. |
Quote:
If you were wrong, you would've been jumped and raped totally by now -.- |
| All times are GMT +2. The time now is 07:07 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.