View difference between Paste ID: ZgmytdU4 and jPdni2Lx
SHOW: | | - or go back to the newest paste.
1
function scheduleFromFile(path)
2
    local file = fs.open(path, "r")
3
	local body = file.readAll()
4-
    print("ERROR: Please specify a file location.")
4+
	file.close()
5-
    return
5+
    return textutils.unserialize(body)
6
end
7
8-
local station = peripheral.find("Create_Station")
8+
function scheduleFromStation()
9-
local file = fs.open(filePath, "r")
9+
	return peripheral.find("Create_Station").getSchedule()
10-
local body = file.readAll()
10+
11-
file.close()
11+
12-
local schedule = textutils.unserialize(body)
12+
13-
schedule["color"] = nil
13+
14-
station.setSchedule(schedule)
14+
local schedule
15-
print("Successfully set train schedule to \""..filePath.."\".")
15+
16
    schedule = scheduleFromStation()
17
else
18
    schedule = scheduleFromFile(filePath)
19
end
20
21
local color = schedule.color
22
if color == nil then
23
    color = 2048
24
end
25
term.setTextColor(colors.white)
26
term.setBackgroundColor(colors.black)
27
term.clear()
28
29
local i = 1
30
for _, entry in ipairs(schedule.entries) do
31
    if entry.instruction.id == "create:destination" then
32
		local name = entry.instruction.data.text:gsub("%s%d+$", "")
33
		term.setCursorPos(4, i)
34
        term.write(name)
35
		i = i + 1
36
	end
37
end
38
term.setBackgroundColor(color)
39
for j=1,i-1 do
40
    term.setCursorPos(2, j)
41
    term.write(" ")
42
--    if j == 1 or j == i-1 then
43
--        term.write("O")
44
--    else
45
--        term.write("|")
46
--    end
47
end
48
term.setBackgroundColor(colors.black)
49
term.setCursorPos(1, i)