Minecraft ComputerCraft Wiki
Advertisement
2012-09-01 01.41

The outside of the clock

I've been working on coding a countdown clock and this is what I turned up with.


Features:

  • Easy to customize time amounts
  • Can be extended to up to 4 digit displays
  • The ring around the digits are the seconds.
  • Code is 139 lines long, only 2870 in length
  • Size is around 24x24x6

Btw I'm not releasing the source, but I will try to help others with any code they need help with


Codeman862:

Here is some code I wrote (requires computercraft and redpower). You can change the segment wire colors in the array at the top. Every cable is connected via a bundled cable. just call setNum(Number)!

-- Written by Codeman862
seg = {colors.blue,colors.green,colors.red,colors.orange,colors.lime,colors.white,colors.cyan}

cableSide = "left"

--Chart of segment colors (front)
--
--     Green2
--Blue1      Red3
--     Cyan7
--White6     Orange4
--     Lime5
function setNum(num)
 allOff(1)
 if(num==1) then
  setOutputMass(seg[3]+seg[4])
 elseif(num==2) then
  setOutputMass(seg[2]+seg[3]+seg[5]+seg[6]+seg[7])
 elseif(num==3) then
  setOutputMass(seg[2]+seg[3]+seg[4]+seg[5]+seg[7])
 elseif(num==4) then
  setOutputMass(seg[1]+seg[3]+seg[4]+seg[7])
 elseif(num==5) then
  setOutputMass(seg[1]+seg[2]+seg[4]+seg[5]+seg[7])
 elseif(num==6) then
  setOutputMass(seg[1]+seg[2]+seg[4]+seg[5]+seg[6]+seg[7])
 elseif(num==7) then
  setOutputMass(seg[2]+seg[3]+seg[4])
 elseif(num==8) then
  setOutputMass(seg[1]+seg[2]+seg[3]+seg[4]+seg[5]+seg[6]+seg[7])
 elseif(num==9) then
  setOutputMass(seg[1]+seg[2]+seg[3]+seg[4]+seg[5]+seg[7])
 elseif(num==0) then
  setOutputMass(seg[1]+seg[2]+seg[3]+seg[4]+seg[5]+seg[6])
 end
end

function setOutputMass(segs)
 redstone.setBundledOutput(cableSide,segs)
end

function allOff(disp)
 if(disp==1) then
  redstone.setBundledOutput(cableSide,0)
 end
end


-- Runs a test of the numbers, you can put your own code here
for i=0, 9 do
 sleep(3)
 allOff(1)
 sleep(0.5)
 print(i)
 setNum(i)
end

Dang glitchy code tags!

Advertisement