Type of Loops what they do?

For some reasons, I still not so clear with each type of loops. There are more than one type of loops and they all seem can perform the same thing. What I don't understand is the distinctive of each type?
for loops: when you know how many times you want to iterate. eg: for i = 1 to 5.

While loops: when you can loop infinitely cause you don't know how many times you're going to iterate.

Those are the basic loops.

Everything else is similar in logic but has their own purposes I guess (don't know their impact on low-level).

Do...While means you will do it at least once and then check if you want to continue looping.
There is loop do too.
for loops: when you know how many times you want to iterate. eg: for i = 1 to 5.

While loops: when you can loop infinitely cause you don't know how many times you're going to iterate.

Those are the basic loops.

Everything else is similar in logic but has their own purposes I guess (don't know their impact on low-level).

Do...While means you will do it at least once and then check if you want to continue looping.
A better explained with samples would be more helpful, pal.

I know For loop is to set specific values. For (i=0; i <=10; i ++)

what about For Each?

Do loops

While loops

any more of loop type?
http://www.tutorialspoint.com/ruby/ruby_loops.htm

You asked for the difference between different types of loops. Samples are available all over the internet, and there are people and organizations that spend days of their lives trying to write nice, simple articles to explain the same concepts.

I told you for loops and while loops are the essentials and if you understand how they're used then all other variations are clear when you go and read their descriptions.

Things like "until i < 3" are just, arguably, clearer ways to say "while not i < 3"

You'd find it easier to answer your own questions by picking up an IDE and actually looking at what the code does, based on some sample syntax, and learning ruby using ruby, not learning ruby based on some programming language you might have learned before (java, C, I don't know)

You learn how a tool works by using it and reading the reference manual.
while - Repeats the code in the block until the condition passed to it becomes false. Probably the most common type of loop; just remember to actually change the condition in the loop somewhere, or the loop will run forever.

until - Opposite of while; more of a convenience option. Repeats the code until the condition passed to it becomes true.

for - If you're using something like C or Java, note that for loops in Ruby are more like foreaches; you use them to "iterate" over an array or a hash. For example...



Code:
numbers = (1...5).to_a
for num in numbers
    puts num
end
In this case, num would be set to 1, then 2, then 3, and so on, repeating for each entry in the array. Of course, you could always use each and a block instead.
small correction:

loop isn't really a standard loop.

Its a hack in the Kernel, using a while loop:

NOTE: Not the actual code, but just the jist of it



Code:
module Kernel
  def loop
    while true do
      yield
    end
  end
end

loop do
  puts ":3 Herp derp"
  sleep 3.0
end
for invokes each on an object.

For example



Code:
module Woot
  def self.each
    10.times do yield rand(20) end
  end
end
for num in Woot
  puts num
end
:3
I have been trying to figure out how to make use of a looping function that would allow me to make it so tp generates in real time and monsters have individual timers during battle.

I attempted to make use of a while loop and it seems to make the game hang as though the loop never resolves. Not sure how to set this up to work like in the background rather than pause the entire battle script indefinitely...
A game loop is not the same as just running a while loop.

Each iteration you need to update the graphics (scene, sprites, etc), check for input, and other things. That is why you are given the illusion that things are actually happening. Otherwise how would you play an animation?

You will need to piggyback your code with the existing Update methods provided (or write your own update method, but I suspect you would just want to use what Scene_Battle already gives you)
Hmmm do you mean call an event every second during battle or something to that effect? What existing update methods do I have at my disposal?
Basically everything has an update method. You just need to figure out where you want to put the code that should be run everytime an update is called.
I understand that. My biggest challenge has been understanding the code that is currently in place so I know where to place my own loop that does everything I need while still satisfying the rest of the games functionality... If that makes sense...
Please do not hijack existing (and old) threads. Create a new thread with your question. Closed.

Original thread: https://forums.rpgmakerweb.com/threads/type-of-loops-what-they-do.2901/