generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Do while loops

Previous Thread :: Next Thread 
SimplifiedCode is online. SimplifiedCode
Joined: 26 Jul 2012
Total Posts: 1366
13 Jul 2017 03:27 PM
are they a thing yet

if not add em


- Simp
Report Abuse
SquidyBroh is not online. SquidyBroh
Joined: 08 Jul 2015
Total Posts: 221
13 Jul 2017 04:01 PM
while ... do
--code
end
Report Abuse
nullfeels is not online. nullfeels
Joined: 31 Mar 2017
Total Posts: 1215
13 Jul 2017 04:03 PM
http://wiki.roblox.com/index.php?title=Loops#Repeat

Basically works the same way.
Report Abuse
nullfeels is not online. nullfeels
Joined: 31 Mar 2017
Total Posts: 1215
13 Jul 2017 04:23 PM
Just to clarify(for some reason I always feel compelled to do this) when I say basically I mean It does the same thing, but the name is different. :P

So instead of do...while it's repeat...until, but functionally they are identical.
Report Abuse
Zawie is not online. Zawie
Joined: 04 Jul 2010
Total Posts: 6338
13 Jul 2017 04:24 PM
while (condition) do
--code
end
Report Abuse
nullfeels is not online. nullfeels
Joined: 31 Mar 2017
Total Posts: 1215
13 Jul 2017 04:34 PM
He wanted do...while not while...do. There is a difference in that while evaluates the condition first before executing the contents of the loop. do...while will always execute the code in the loop at least once. repeat...until works the same way as do...while.
Report Abuse
Zawie is not online. Zawie
Joined: 04 Jul 2010
Total Posts: 6338
13 Jul 2017 04:36 PM
ah

repeat
-- code
until (condition)

Report Abuse
SimplifiedCode is online. SimplifiedCode
Joined: 26 Jul 2012
Total Posts: 1366
13 Jul 2017 05:25 PM
No...

In C++ there is while loops, also do while loops:

do {

} while (condition)


- Simp
Report Abuse
nullfeels is not online. nullfeels
Joined: 31 Mar 2017
Total Posts: 1215
13 Jul 2017 05:41 PM
@SimplifiedCode, yes and the functional equivalent of this in Lua is repeat...until

They do the same thing just have different names.
Report Abuse
SimplifiedCode is online. SimplifiedCode
Joined: 26 Jul 2012
Total Posts: 1366
13 Jul 2017 05:43 PM
That wouldn't do the same thing. it would repeat it, not do it once and then check if it was "Right"


- Simp
Report Abuse
nullfeels is not online. nullfeels
Joined: 31 Mar 2017
Total Posts: 1215
13 Jul 2017 05:50 PM
http://wiki.roblox.com/index.php?title=Loops

No, it executes the code within the loop once and then checks the condition to see if it evaluates to true. This IS the exact same things do...while loops do...


in Lua:

local i = 0
repeat
i = i + 1
until (i == 10)

in C++:

int i = 0;
do {
i++;
} while(i < 10);

Is functional identical. Lua doesn't need to add do...while loops because it has repeat...until. Which works MORE OR LESS the same.
Report Abuse
SimplifiedCode is online. SimplifiedCode
Joined: 26 Jul 2012
Total Posts: 1366
13 Jul 2017 05:53 PM
No...

local i = 0
repeat
i = i + 1
until (i == 10)

> Checking Repeats 10 times

int i = 0;
do {
i++;
} while(i < 10);

> Repeats 10 times then checking.




- Simp
Report Abuse
nullfeels is not online. nullfeels
Joined: 31 Mar 2017
Total Posts: 1215
13 Jul 2017 06:00 PM
In both the condition is always evaluated after every iteration of the loop.

local i = 0
print(i)
i = i + 1
until (i == 3)

will print 0 regardless as the loop is executed before the condition is checked

execute loop > check condition > i == 3? yes: end, no: execute loop
Report Abuse
SimplifiedCode is online. SimplifiedCode
Joined: 26 Jul 2012
Total Posts: 1366
13 Jul 2017 06:01 PM
I see.


- Simp
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image