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

ThermalExpansion Clock

Started by MissYijare, 12 March 2014 - 04:28 PM
MissYijare #1
Posted 12 March 2014 - 05:28 PM
Hey there, i'm kind of trying to build myself a Digital Clock out of the Thermal Expansion "Glowstone Illuminators", as I know you can color them with one Turtle sitting behind them and giving them a color.


Anyways, let's look what i'm talking about.


(click them)

Each of the "Number" blocks has one turtle behind it.

They should be able to count upwards if supplied with redstone/what ever signal. Even if the server restarts the programm should be able to set the clock on the elapsed time again.

Like 1:45.32 - server crash (what so ever) and the programm should be able to restore that.


For the Turtles:

local lamp = peripheral.wrap("front")

while true do

if rs.getInput("back") == true then
lamp.setColorblack)
else
lamp.setColor(white)

end



I'm sure i can do this the sameway with wireless rednet, but i'm a bit confused with that one.

then i have to set the redstone outputs, right?

so for each of the 7 segments of the number thre has to be a signal… halP?!
Edited on 12 March 2014 - 06:49 PM
CometWolf #2
Posted 12 March 2014 - 06:49 PM
Oh my what an unessacary use of materials, even though you obviously are in creative :P/> I've never used the illuminators myself, but this is probably a lot easier to manage if you just use wired cables and modems instead of turtles, that way you can controll it all with one computer directly. Your question is kind of vague however, do you want the function for setting redstone output or what?
MissYijare #3
Posted 12 March 2014 - 07:49 PM
well, no, only engeneering turtles can make the illuminattors change color. not simple on off. that i would have managed myself, i think.

i was aiming for an main computer controlling the lot of them.
OReezy #4
Posted 12 March 2014 - 08:03 PM
This is just a thought but I would try making two tables. One table would contain the IDs of all the turtles in each digit in the same order for each table. The second table would be for tables that hold locations numbers themselves. So whichever slot needs to be lit up would get a rednet message.

So if you need to display a seven, you would use the numbers in the table holding the locations for the number seven, and send it to turtles in the table for which digit you want to display it in.

I imagine this sounds kind of weird, so if its hard to understand what I'm trying to say let me know and I will make a picture.
MissYijare #5
Posted 13 March 2014 - 02:26 AM
i don't understand at all :/
OReezy #6
Posted 13 March 2014 - 03:55 AM
First you would need an order for your turtles, and it would look something like this
Spoiler
So for each digit, you would index the turtle IDs in a table in that order. Next you would use it to determine which turtles you needed to make a number. So for the number seven you would need: 1, 2, 3, 5, 7, 9, 14, 16, 18.
local digits = {} --Holds the tables for the digits
digits[1] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18} --All the turtle IDs in the first digit
local numbers = {}
numbers[7] = {1, 2, 3, 5, 7, 9, 14, 16, 18} --The turtle locations needed to make the number seven
Now use a loop to use the numbers in your "numbers" table to send a message to the necessary turtles in your "digits" table
for i = 1, #numbers[7] do
  rednet.send(digits[1][numbers[7][i]], "message") --Sends a message to all the turtles in the first digit whose location matches that of the numbers in your table for seven
end
Then you have some code on the turtles that tells it to change colors when it receives a certain message.

This is all untested and there may be better ways to do it but this is what I thought of to use turtles.
MissYijare #7
Posted 16 March 2014 - 03:47 AM
let me try this out then…


local digits = {} --overall

local seg1 = {} --segments for digit 1

seg1[1] = { 3, 4, 5 } --bottom
seg1[2] = { 6, 7, 8 } -- bottom right
seg1[3] = { 9, 10, 11 } --bottom left
seg1[4] = { 12, 13, 14 } --middle
seg1[5] = { 15, 16, 17 } --top  right
seg1[6] = { 18, 19, 20 } --top left
seg1[7] = { 21, 22, 23 } --top

local seg2 = {} --segments for digit 2

seg2[1] = { 24, 25, 26 }
seg2[2] = { 27, 28, 29 }
seg2[3] = { 30, 31, 32 }
seg2[4] = { 33, 34, 35 }
seg2[5] = { 36, 37, 38 }
seg2[6] = { 39, 40, 41 }
seg2[7] = { 42, 43, 44 }

local seg3 = {} --segments for digit 3

seg3[1] = { 46, 47, 48 }
seg3[2] = { 49, 50, 51 }
seg3[3] = { 52, 53, 54 }
seg3[4] = { 55, 56, 57 }
seg3[5] = { 58, 59, 60 }
seg3[6] = { 61, 62, 63 }
seg3[7] = { 64, 65, 66 }

local seg4 = {} --segments for digit 4

seg4[1] = { 67, 68, 69 }
seg4[2] = { 70, 71, 72 }
seg4[3] = { 73, 74, 75 }
seg4[4] = { 76, 77, 78 }
seg4[5] = { 79, 80, 81 }
seg4[6] = { 82, 83, 84 }
seg4[7] = { 85, 86, 87 }

local seg5 = {} --segments for digit 5

seg5[1] = { 90, 91, 92 }
seg5[2] = { 93, 94, 95 }
seg5[3] = { 96, 97, 98 }
seg5[4] = { 99, 100, 101 }
seg5[5] = { 102, 103, 104 }
seg5[6] = { 105, 106, 107 }
seg5[7] = { 108, 109, 110 }

local seg6 = {} --segments for digit 6

seg6[1] = { 111, 112, 113 }
seg6[2] = { 114, 115, 116 }
seg6[3] = { 117, 118, 119 }
seg6[4] = { 120, 121, 122 }
seg6[5] = { 123, 124, 125 }
seg6[6] = { 126, 127, 128 }
seg6[7] = { 129, 130, 131 }

local seg7 = {} --segments for digit 7

seg7[1] = { 132, 133, 134 }
seg7[2] = { 135, 136, 137 }
seg7[3] = { 138, 139, 140 }
seg7[4] = { 141, 142, 143 }
seg7[5] = { 144, 145, 146 }
seg7[6] = { 147, 148, 149 }
seg7[7] = { 150, 151, 152 }

--seconds
digits[1] = { seg1[1], seg1[2], seg1[3], seg1[4], seg1[5], seg1[6], seg1[7] }
digits[2] = { seg2[1], seg2[2], seg1[3], seg2[4], seg2[5], seg2[6], seg2[7] }
--minutes
digits[3] = { seg3[1], seg3[2], seg1[3], seg3[4], seg3[5], seg3[6], seg3[7] }
digits[4] = { seg4[1], seg4[2], seg1[3], seg4[4], seg4[5], seg4[6], seg4[7] }
--hours
digits[5] = { seg5[1], seg5[2], seg1[3], seg5[4], seg5[5], seg5[6], seg5[7] }
digits[6] = { seg6[1], seg6[2], seg1[3], seg6[4], seg6[5], seg6[6], seg6[7] }
digits[7] = { seg7[1], seg7[2], seg1[3], seg7[4], seg7[5], seg7[6], seg7[7] }

So making a one in one of these segments would be


digits[1[2,5]]
right?


and yes, ugly code is ugly.
theoriginalbit #8
Posted 16 March 2014 - 03:54 AM
well, no, only engeneering turtles can make the illuminattors change color. not simple on off. that i would have managed myself, i think.
if you have OpenPeripheral installed you can use any Turtle (or a computer) to change the colour of an illuminator (although using a single computer and network cables would be easier!), like so

local lamp = peripheral.wrap("glowstone_illuminator_0") --# or front, or wherever it is
lamp.setColor(0xFFFFFF)
this will set the lamp to white, the format for the colour is

0xRRGGBB
where RR is 00-FF for Red
where GG is 00-FF for Green
where BB is 00-FF for Blue
these 00-FF hex values line up with the 0-255 values in RGB.
Edited on 16 March 2014 - 02:56 AM
Lyqyd #9
Posted 16 March 2014 - 03:55 AM
Or maybe:


local digits = {}
local channel = 2

local digitCount, segments = 7, 7

for i = 1, digitCount do
  digits[i] = {}
  for j = 1, segments do
    digits[i][j] = {}
    for k = 1, 3 do
      channel = channel + 1
      digits[i][j][k] = channel
    end
  end
end

That would construct the same table. But I've no idea what you mean with your question about making a one in a segment. You'd need to do something with the information in the table, not just build the table.
MissYijare #10
Posted 16 March 2014 - 04:01 AM
so I wopuldnt need any turtles and could connect the illuminators per cable modem? oO
theoriginalbit #11
Posted 16 March 2014 - 04:12 AM
so I wopuldnt need any turtles and could connect the illuminators per cable modem? oO
as long as you have OpenPeripheral installed, yes. You could place a wired modem on all the illuminators and turn them on, if you're clever about the way you can turn them on then you can actually do some tricky stuff in your code. So if you turn them on in a certain order you'd know which ones would be which ID and then just make the appropriate colour change call to the specific one when needed.
MissYijare #12
Posted 16 March 2014 - 04:15 AM
the hing is, it#s a clock so it would make constant changes to the displayed things.


it has 888:88.88 as max but first it should only display
00:00.01 -> 2 etc. I know how to make it semi vanilla, but i tought computercraft could do it for me
Lyqyd #13
Posted 16 March 2014 - 04:29 AM
It can, you just have to code it to do so for you.
MissYijare #14
Posted 16 March 2014 - 02:48 PM
yeah there lies the proplem. I know how to get the respone for making the lamps go white/black


local lamp = peripheral.wrap("front")

while true do
  if signal() == true then
   lamp.setColor(0x000000)
  else
   lamp.setColor(0xFFFFFF)
  end
end