4 posts
Location
PerryHall MD
Posted 06 May 2013 - 12:02 PM
"Title" Need Help With A Simple Aesthetics Program
I Am Trying To Make A Basic Loading Screen For My Program. Here Is My code So Far. (I Know It's Repetitive But I Haven't Quite Figured Out Loops Yet…)
print("Initializing")
sleep(2)
print("Loading /")
sleep(2)
print("Loading --")
sleep(2)
print("Loading \")
sleep(2)
print("Loading --")
sleep(2)
print("Loading /")
sleep(2)
print("Loading --")
sleep(2)
print("Loading /")
sleep(2)
print("Loading --")
end
3790 posts
Location
Lincoln, Nebraska
Posted 06 May 2013 - 12:26 PM
Split to new topic.
What you are looking for is a for loop.
Simple for loop syntax:
for <iterator> = <start> , <stop> , <steps in between> do
--code here
end
--Example:
for i = 0, 5 do
print( "Slept " .. i .. " seconds." )
sleep( 1 )
end
EDIT: Just as a personal aside, fake loading screens are annoying. I hate them, and if you plan on releasing code to the forums, I would omit them, as many others hate them too. They serve no other purpose than to make you wait.
Edited on 06 May 2013 - 10:27 AM
4 posts
Location
PerryHall MD
Posted 06 May 2013 - 12:36 PM
That is True But Some People Also May Want Aesthetics To Spiff Up they're OS's.
Plus You Can't Really Just Omit Something You don't Like, Plus it Doesn't Break The Rules And Guidelines In Any Way.
EDIT: And Also It's Mostly Just For Me To Learn Simple Code. I'm not Planning On Releasing This Code Except Maybe As Part of My friend And My OS.
758 posts
Location
Budapest, Hungary
Posted 06 May 2013 - 12:45 PM
BTW… "-" takes as much space horizontally as a "/" or a "\", so no need of using two of them. Actually, that would look a bit off.
4 posts
Location
PerryHall MD
Posted 06 May 2013 - 12:55 PM
Ok, didn't Know That, Thanks For The Tip ;D
169 posts
Posted 06 May 2013 - 12:55 PM
[…] Just as a personal aside, fake loading screens are annoying. I hate them, and if you plan on releasing code to the forums, I would omit them, as many others hate them too. They serve no other purpose than to make you wait.
Honestly, I think some people take this a bit too far (the hatred of loading screens, that is). Sure, irrelevant loading screens are annoying and pointless. But there are some programs that take a long time to do certain things (anything with the HTTP API) and, during that time, the program doesn't accept any other input. It would be nice if these programs incorporated a loading screen, just so that the user knows what it is happening. Otherwise, the user might just terminate the program.
3790 posts
Location
Lincoln, Nebraska
Posted 06 May 2013 - 01:04 PM
Oh, I wasn't looking down on you, I was just letting you know that fake loading screens annoy me. You can put it in, but I was just warning you that others might not like it as much as you do.
But yes, in order to repeat something, you want a for loop. You can use a table to accomplish this:
local loadTable = { "-", "/", "|", "\\" }
--keep in mind when doing a backslash ( \ ), you must use two, since the \ is considered an escape character.
for i = 1, #loadTable do
print( "Loading... " .. loadTable[ i ] )
sleep(2)
end
Edited on 06 May 2013 - 11:11 AM
1583 posts
Location
Germany
Posted 06 May 2013 - 01:44 PM
Oh, I wasn't looking down on you, I was just letting you know that fake loading screens annoy me. You can put it in, but I was just warning you that others might not like it as much as you do.
But yes, in order to repeat something, you want a for loop. You can use a table to accomplish this:
local loadTable = { "-", "/", "|", "\\" }
--keep in mind when doing a backslash ( \ ), you must use two, since the \ is considered an escape character.
for i = 1, #loadTable do
print( "Loading... " .. loadTable[ i ] )
sleep(2)
end
I don't think that a loadingscreen like this looks good:
-
/
|
\\
Improvment:
for i = 1, 5 do
write("-")
end
looks like this:
-----
758 posts
Location
Budapest, Hungary
Posted 06 May 2013 - 01:56 PM
-snip-
Yeah, Cranium forgot a .setCursorPos, but that rotating (yup, it should be rotating) thingie is better than a bunch of hyphens…
EDIT: I belive I saw that kind of loading indicator in… SUPER ©?
2217 posts
Location
3232235883
Posted 06 May 2013 - 02:11 PM
I don't think that a loadingscreen like this looks good:
Improvment:
for i = 1, 5 do
write("-")
end
looks like this:
-----
use string.rep("-",5) instead of a for loop
its more of a loading bar than a rotating line for things that dont really have a completion percentage