Zaxerion
|
  |
| Joined: 09 Feb 2013 |
| Total Posts: 2304 |
|
|
| 23 Oct 2015 03:06 PM |
What is InfinityBloc? IB is a new scripting group bent on making the experience better for everyone! There is no group, but we will have one soon. InfinityBloc aims to teach new users RBX.Lua and prepare them for learning real programming languages. We lightly cover the topics, teaching them enough, but we only go deep enough to teach and not confuse. Thank you for reading!
First off, what is a loop? A loop is a chunk of code that runs multiple time.
What kinds of loops are there? There are for loops, while loops, and repeat loops. There are other methods, but we won't get into that today.
SECTION ONE, WHILE LOOP
A while loop will run the code while the condition is true, or condition exists. To print hi, we will check if condition is equal to true.
while (condition) do print('Hi!') end
output:
>> Hi!
Expirement with this. Please notice, you can use the or/and operators to check if other ones are true/exist to, and run it then instead.
SECTION TWO, FOR LOOP
A for loop is a bit more flexible. We can make it run one time, or fifty times. It runs it no matter what, but you can fix that with a(n) if statement..
We use for i = [...] because i stands for the # of iterations were on. i can be named anything you want.
Lets print Hello User 10 times!
for i = 1,10,1 do print('Hello User') end
Output:
Hello User Hello User Hello User Hello User Hello User Hello User Hello User Hello User Hello User Hello User
The first parameter is the number to start on, the second is the number of iterations to do, and the third is the increment to move by. I am sure you get this now, it is pretty simple!
SECTION THREE, REPEAT LOOPS
Repeat repeatedly runs the code until the condition is true/exists. It is just like a while loop, but works slightly differently. Heres an example:
local Condition = 0
repeat print('Hi') Condition = Condition + 1 wait() until Condition >= 10
output:
Hi Hi Hi Hi Hi Hi Hi Hi Hi Hi
It will print Hi about every 1/30 of a second ten times. How could we make this more efficient based off what you learned so far? Whats that? A for loop? Absolutely! Good!
Simple, right? Challenge: Figure out how to repeatedly put a brick at each players mouse position using a loop of your own choice! Post how you did the challenge, including the code your willing to share!
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Note: BE CAREFURE WHEN RUNNING LOTS OF ITERATIONS - It will crash if you don't yield!
Good luck and thanks for constructive feedback! |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
Zaxerion
|
  |
| Joined: 09 Feb 2013 |
| Total Posts: 2304 |
|
|
| 23 Oct 2015 03:07 PM |
Cnt, this is suposed to be dumbed down. Plus, I doubt you had time to read it. |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 03:09 PM |
| You should only create tutorials if you are competent enough and that you know it is 100% true. |
|
|
| Report Abuse |
|
|
Zaxerion
|
  |
| Joined: 09 Feb 2013 |
| Total Posts: 2304 |
|
|
| 23 Oct 2015 03:10 PM |
| I know I am not 100% good, but I think this will help new users. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Oct 2015 03:25 PM |
| You're not helping anyone, you're just making yourself look stupid because of how little you understand Lua and loops and you are misleading and confusing people. Leave. |
|
|
| Report Abuse |
|
|
| |
|
Zaxerion
|
  |
| Joined: 09 Feb 2013 |
| Total Posts: 2304 |
|
|
| 23 Oct 2015 03:33 PM |
| If they do I will just think of a clever way to still get it. |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Oct 2015 03:44 PM |
| I don't think anyone will join this group. There are already a lot, and they have a lot of regulars like SFBC. |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 03:49 PM |
| Sadly beginners don't come to forums, usually the newbies come here just to ask to script them stuff. |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 03:52 PM |
Constructive Feedback: -It's too vague, even for a dumbed-down guide. -You should have gave real-life scenarios. -The formatting is unpleasant (no offense). -There literally only like 2-3 lines for each sections...
|
|
|
| Report Abuse |
|
|
Zaxerion
|
  |
| Joined: 09 Feb 2013 |
| Total Posts: 2304 |
|
|
| 23 Oct 2015 04:06 PM |
-its a light guide, you assumed it doesnt go in depth later. it does. - no, this is for pc. not real life -your opinion, i like it this way. it will take a majority to make me change it. -as i said, this goes slowly. more gets taught later on. and theres like 8 lines. |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 04:07 PM |
| For the 2nd, you completely mis-interpreted what I meant. :P |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 04:12 PM |
| Yes, but anyone could learn much more from PIL, and even the wiki. |
|
|
| Report Abuse |
|
|
Zaxerion
|
  |
| Joined: 09 Feb 2013 |
| Total Posts: 2304 |
|
|
| 23 Oct 2015 04:14 PM |
| i said constructive, not hating |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 04:16 PM |
Oh, you are the people that can't take any criticism and are always in denial, like everyone on Kitchen Nightmares. "No, this is a dumb-downed guide" it really isn't. You can find out much more on PIL or the wiki, and those are sort of dumbed-down.
You need to stop being in denial, and stop calling everyone haters when they say your tutorial is useless. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 23 Oct 2015 04:18 PM |
| I'm pretty sure you're going to consider anything constructive "hating". Problem is, there's a ton of problems with this guide; it's not very good. There's no way to soften that. |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 05:30 PM |
| while loop will crash the game without a wait |
|
|
| Report Abuse |
|
|
Zaxerion
|
  |
| Joined: 09 Feb 2013 |
| Total Posts: 2304 |
|
|
| 23 Oct 2015 05:31 PM |
| Repaer, that was also noted.. |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 05:32 PM |
if you can't script, don't make a tutorial
NOOB BISQUE |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 05:32 PM |
i represents 1-10 by increments of 1 but you don't use it anywhere when you print "Hello User"
wouldn't it only print once? |
|
|
| Report Abuse |
|
|
Zaxerion
|
  |
| Joined: 09 Feb 2013 |
| Total Posts: 2304 |
|
|
| 23 Oct 2015 05:32 PM |
| it would print every iteration |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 05:34 PM |
for index = 1, 10 do print("Hello world") end
This will print Hello world 1, 10 times
1, 2, 3, 4, 5, 6, 7, 8, 9, 10 10 times ^
index iterates through the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
and for each iteration it does what is in the for loop's block
for index = 1, 10 do print("Hello world") end
no idea if this is how it works, it's just what sounds right inside my head. |
|
|
| Report Abuse |
|
|
|
| 23 Oct 2015 05:35 PM |
but you don't even use i
wouldn't it be control = 0 for i = 1, 10 do if control < 10 then print("Hello User") control = i end end |
|
|
| Report Abuse |
|
|