forked from lauradissinger/Minecraft-ComputerCraft-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClock.lua
More file actions
63 lines (51 loc) · 1.4 KB
/
Copy pathClock.lua
File metadata and controls
63 lines (51 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- Clock for display on a monitor
-- Author: CecilKilmer
-- Version: 1.0
-- Date: 2013/09/15
-- Min width required (IE: 10:00 PM)
minWidthReq = 8
minHeightReq = 2
-- Figure out where our monitor is
monitorSide = nil
monitor = nil
if peripheral.getType("left") == "monitor" then
monitorSide = "left"
elseif peripheral.getType("right") == "monitor" then
monitorSide = "right"
elseif peripheral.getType("top") == "monitor" then
monitorSide = "top"
elseif peripheral.getType("bottom") == "monitor" then
monitorSide = "bottom"
elseif peripheral.getType("front") == "monitor" then
monitorSide = "front"
elseif peripheral.getType("back") == "monitor" then
monitorSide = "back"
end
screenWidth = 0
screenHeight = 0
-- If we have one, redirect term to it
if monitorSide ~= nil then
monitor = peripheral.wrap(monitorSide)
term.redirect(monitor)
local scale = 5.5
repeat
scale = scale - 0.5
monitor.setTextScale(scale)
screenWidth, screenHeight = term.getSize()
until screenWidth > minWidthReq and screenHeight > minHeightReq
end
-- Determine our screen size
screenWidth, screenHeight = term.getSize()
yPos = screenHeight - minHeightReq
yPos = math.floor(yPos / 2)
-- Main loop
while true do
term.clear()
local time = os.time()
time = textutils.formatTime(time, false)
local xPos = screenWidth - string.len(time)
xPos = math.ceil(xPos / 2)
term.setCursorPos(xPos + 1, yPos + 2)
print(time)
sleep(.1)
end