This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ZdecydowanieJa's profile picture

How to make a splash screen.

Started by ZdecydowanieJa, 13 August 2012 - 01:37 PM
ZdecydowanieJa #1
Posted 13 August 2012 - 03:37 PM
Hello, this is my first post. I'll show you how to make a splash screen for your program.

1.Write function named "job" for loading program's settings etc. (make sure there isn't any prints and something else that showing something on screen)

function job()
  --some loading stuff
end

2.Write function named "splash" that shows splash screen in infinity loop, for example:

function splash()
  while(true) do
	print("sweet splash");
    sleep(1);
	shell.run("clear");
  end
end
3.To run splash screen, call

parallel.waitForAny(job, splash);

Well done!

//Sorry for my english, i'm only 12 years old, and i'm from poland.


Wersja Polska/Polish version:

Siemka, to mój pierwszy post. Pokażę ci jak zrobić ekran powitalny/ładowania dla twojego programu.

1.Napisz funkcję nazwaną "job" która ładuje ustawienia i tym podobne. (upewnij się, że funkcja nie pokazuje nic na ekranie!)

function job()
  --ładowanie itd.
end

2.Napisz funkcję nazwaną "splash" która pokazuje ekran w nieskończoność:

function splash()
  while(true) do
	print("super ekran powitalny");
    sleep(1); --żeby nie crashowało
	shell.run("clear");
  end
end
3.Aby odpalić ekran wywołaj:

parallel.waitForAny(job, splash);

Well done!
Cranium #2
Posted 13 August 2012 - 05:50 PM
For being 12 and Polish, your english is great!
ardera #3
Posted 13 August 2012 - 07:11 PM
Your'e right! His english is good!
ElvishJerricco #4
Posted 01 September 2012 - 06:59 PM
I don't understand why you have to run them in parallel. Why not just make sure the job doesn't do any print(), print the splash and be done with it?
IceCream #5
Posted 03 September 2012 - 05:10 AM
Nice English buddy :D/>/>


Could you tell me what your username means? Is it your name?
Noodle #6
Posted 03 September 2012 - 07:25 AM
So.. What is the point for this? Have something on the main while loading stuff?
Why not just
print("Splash")
-- internal code here that doesn't print anything
Nice English :D/>/>
Sariaz #7
Posted 23 September 2012 - 08:27 AM
So.. What is the point for this? Have something on the main while loading stuff?
Why not just
print("Splash")
-- internal code here that doesn't print anything
Nice English :P/>/>

i think the reason is because if u have a more advanced splash screen like if u have a carector bounce around the screen instead of just printing something his/her way would work were your idea wouldn't. If ur just doing a splash text though your way would be better.
Sariaz #8
Posted 14 April 2013 - 08:08 PM
Now looking back at this after some more coding experience I think the point of running in parallel is so that you can have a while loop running the splash which if is animation would be hard to integrate with loading process as I said before. What I realize now is because its wait for any as soon as the jobs function finishes its work and loads that function will finish automatically ending the splash function.
superaxander #9
Posted 14 April 2013 - 08:35 PM
You could also do this

function job()
      --do stuff
end
function splash()
     print("A wonderful splash screen")
end
parrallel.waitForAll(job, splash)
term.clear()
term.setCursorPos(1,1)
Less flickering and no sleep needed and no loop
TariqCrazymanTc0 #10
Posted 22 April 2013 - 02:12 AM
Cool A Polish Person That Haz Good English Thumbs Up For This Topic Its Really Good Due To It Having Multiple Languages
Spongy141 #11
Posted 22 April 2013 - 10:12 AM
I don't recall Lua needing ; after a line of code, or having to have a while true loop do while (true) do…. But nice English.
Lyqyd #12
Posted 22 April 2013 - 11:16 AM
The semicolon terminating the line is unnecessary, but I don't believe it has any detrimental effects.
SuicidalSTDz #13
Posted 22 April 2013 - 01:08 PM
or having to have a while true loop do while (true)
It's a preference.


local function foo(num1,num2)
  return (num1) > (num2)
end
print(foo(tonumber( read() ), tonumber( read() )))

num1 and num2 do not need quotation. It is purely a preference.
Spongy141 #14
Posted 22 April 2013 - 02:20 PM
or having to have a while true loop do while (true)
It's a preference.


local function foo(num1,num2)
  return (num1) > (num2)
end
print(foo(tonumber( read() ), tonumber( read() )))

num1 and num2 do not need quotation. It is purely a preference.
Its kinda needed, since it would be very difficult to tell whats what without the (), but still a while true do loop doesn't necessarily need it.
Espen #15
Posted 22 April 2013 - 09:13 PM
num1 and num2 do not need quotation. It is purely a preference.
They are parantheses, bot quotations.^^

And you would need them if you'd want to change processing priorities of an expression, like:
local var1 = true
local var2 = false
local var3 = false

local result1 = (var1 or var2) and var3   -- Returns false
local result2 = var1 or var2 and var3   -- Returs true
SuicidalSTDz #16
Posted 23 April 2013 - 02:20 AM
num1 and num2 do not need quotation. It is purely a preference.
They are parantheses, bot quotations.^^

And you would need them if you'd want to change processing priorities of an expression, like:
local var1 = true
local var2 = false
local var3 = false

local result1 = (var1 or var2) and var3   -- Returns false
local result2 = var1 or var2 and var3   -- Returs true
I don't know why I said quotation <_</> and yes, in that case they are needed.
awsmazinggenius #17
Posted 21 October 2013 - 10:27 PM
I don't understand why you have to run them in parallel. Why not just make sure the job doesn't do any print(), print the splash and be done with it?
You might have a splash screen that says "Loading…", and if you used his way it would actually be loading things.
Lyqyd #18
Posted 22 October 2013 - 02:31 AM
Aaand locked. You posted on a topic that's been dead for six months to reply to a post that's over a year old? Sigh. Please try to at least add something to the topic, since even your counterexample doesn't require parallel.