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

run 2 pices of code at the same time

Started by Crowdy199, 30 January 2013 - 10:08 AM
Crowdy199 #1
Posted 30 January 2013 - 11:08 AM
i am making an os i want it to show the logo and sleep(2) then go to the next screen how do i make it run alot of code making functions while it is dislpaying the logo for 2 seconds
tesla1889 #2
Posted 30 January 2013 - 03:26 PM
Lua doesn't allow for actual multitasking, but, using the parallel API, you can switch between two (or more) functions

and, it will be at least two seconds, but you can't limit it to at most two seconds


local dispLogo = function()
-- code to display logo
sleep(2)
-- code to run next program
end
local loadShellDrivers = function()
local driver1 = function(...)
  -- code
end
local driver2 = function(...)
  -- code
end
local driver3 = function(...)
  -- code
end
end
parallel.waitForAll(dispLogo,loadShellDrivers)

good luck to you and your shell program

[Edit your darned posts. This is ridiculous. -L]
theoriginalbit #3
Posted 30 January 2013 - 03:31 PM
tesla1889 said:
Heard of edit? :P/>
tesla1889 #4
Posted 30 January 2013 - 03:32 PM
tesla1889 said:
Heard of edit? :P/>
yeah. too lazy lol
Lyqyd #5
Posted 30 January 2013 - 07:40 PM
tesla1889 said:
Heard of edit? :P/>
yeah. too lazy lol

Well, unlazy yourself. Next time, it'll involve a warning.
ChunLing #6
Posted 31 January 2013 - 02:58 AM
Recursing a warning somehow seems very ominous.

"Chris likes chicken, so when he comes home there will be some roast chicken."