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

can someone help simplify this code

Started by unclejunky, 31 May 2014 - 10:43 PM
unclejunky #1
Posted 01 June 2014 - 12:43 AM
i know there is a way to do it, but i forgot how and where i saw it. this code is for a loading bar that will be used for a new startup program.




local lime = 32
local bar = paintutils.drawPixel
bar(8, 5, lime) --1
sleep(.3)
bar(9, 5, lime) --2
sleep(.3)
bar(10, 5, lime) --3
sleep(.3)
bar(11, 5, lime) --4
sleep(.3)
bar(12, 5, lime) --5
sleep(.3)
bar(13, 5, lime) --6
sleep(.3)
bar(14, 5, lime) --7
sleep(.3)
bar(15, 5, lime) --8
sleep(.3)
bar(16, 5, lime) --9
sleep(.3)
bar(17, 5, lime) --10
sleep(.3)
bar(18, 5, lime) --11
sleep(.3)
bar(19, 5, lime) --12
sleep(.3)
Bubba #2
Posted 01 June 2014 - 01:06 AM
Use a for loop.


for x=8,19 do
  paintutils.drawPixel(x, 5, colors.lime)
  sleep(0.3)
end
Edited on 31 May 2014 - 11:09 PM
unclejunky #3
Posted 01 June 2014 - 01:29 AM
that was a huge help, thanks!