-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
60 lines (55 loc) · 1.71 KB
/
Copy pathinit.lua
File metadata and controls
60 lines (55 loc) · 1.71 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
do
-- Get the gpu and proxy it to the screen
local gpu = component.proxy(component.list("gpu")())
local screen = component.proxy(component.list("screen")())
gpu.bind(screen.address)
gpu.setResolution(gpu.maxResolution())
gpu.setBackground(0x000000)
gpu.setForeground(0xFFFFFF)
local w, h = gpu.maxResolution()
gpu.fill(1, 1, w, h, " ")
computer.pullSignal(2)
local function playNote(frequency, duration)
computer.beep(frequency, duration * 1.7)
end
-- Define the notes and their corresponding frequencies and durations
local notes = {
{ frequency = 423.25, duration = 0.1 },
{ frequency = 559.25, duration = 0.1 },
{ frequency = 683.99, duration = 0.2 },
{ frequency = 780, duration = 0.1 },
{ frequency = 559.25, duration = 0.1 }
}
-- Play the notes one by one
for i, note in ipairs(notes) do
playNote(note.frequency, note.duration)
end
local addr, invoke = computer.getBootAddress(), component.invoke
local function loadfile(file)
local handle = assert(invoke(addr, "open", file))
local buffer = ""
repeat
local data = invoke(addr, "read", handle, math.huge)
buffer = buffer .. (data or "")
until not data
invoke(addr, "close", handle)
return load(buffer, "=" .. file, "bt", _G)
end
loadfile("/lib/core/boot.lua")(loadfile)
end
while true do
local reason, err = xpcall(require("shell").getShell(), function(msg)
return tostring(msg).."\n"..debug.traceback()
end)
local gpu = component.gpu
if not reason then
w,h = gpu.getResolution()
computer.beep(1350, 1.6)
gpu.fill(1, 1, w, h, " ")
if not require("shell").getShell() then
error("Shell not found")
else
error(err)
end
end
end