Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ reverse of for loop
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Tkl1129
Hong Kong (43 posts) Bio
|
| Date
| Fri 15 Jul 2011 02:40 PM (UTC) |
| Message
| I have question for "for" function.
Numberic For can
for i = 2,5 do
print(i) -- This return 2 ..3..4..5
end --for
But I want to make a reverse
for i = 5,2 do
print(i) -- Hope display 5..4..3..2..but fail
end --for
do there any method to achieve this?
or only do a stupid thing like
local loop1 = 5 - 2 + 1
local loop2 = 5
for i = 1,loop1 do
print(loop2)
loop2 = loop2 - 1 -- display 5..4..3..2
end-for
Any other method?
Thanks~ | | Top |
|
| Posted by
| Fiendish
USA (2,558 posts) Bio
Global Moderator |
| Date
| Reply #1 on Fri 15 Jul 2011 06:48 PM (UTC) Amended on Fri 15 Jul 2011 06:50 PM (UTC) by Fiendish
|
| Message
| for i=5,2,-1
the for loop has a 3rd parameter implicitly set to 1 if not used for how much to step by |
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
| Posted by
| Tkl1129
Hong Kong (43 posts) Bio
|
| Date
| Reply #2 on Sat 16 Jul 2011 12:38 AM (UTC) |
| Message
| ah..--__--"
yes...How stupid I am !!!..
Thanks~ | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
13,330 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top