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

[Lua] Startup .'s (print .'s every 0.5 until loaded

Started by Mattzz, 17 March 2012 - 11:18 PM
Mattzz #1
Posted 18 March 2012 - 12:18 AM
Hey all,
I was wondering how to make it so a program loads something
but while doing it it writes .'s every 0.5 secs until done in which case it
writes a "Done" also there its gonna be 1 initial . so that it dosnt look rubbish(i know how to do that)
Advert #2
Posted 18 March 2012 - 01:15 AM
You can use a timer:


local dotTimer = os.startTimer(0.5)
local loadTimer = os.startTimer(0)

local function printDot()
 -- Alternatively you could make this different, or check how much is loaded.
 term.write(".")
end

local function loadStuff()
 -- Your loading code in here
end

for sEvent, a, b in os.pullEvent do
 if sEvent == "timer" then
  if a == dotTimer then
   dotTimer = os.startTimer(0.5)
   printDot()
  elseif a == loadTimer then
   loadTimer = os.startTimer(0)
   loadStuff()
  end
 end
end