Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function scheduleFromFile(path)
- local file = fs.open(path, "r")
- local body = file.readAll()
- file.close()
- return textutils.unserialize(body)
- end
- function splitWord(target, word)
- local i, j = string.find(target, word)
- if i == nil then return target end
- return string.sub(target, 1, i - 1), string.sub(target, j + 1, -1)
- end
- schedule = scheduleFromFile("green.line")
- entries = schedule.entries
- progress = schedule.progress
- if progress == nil then progress = 1 end
- stations = {}
- label = nil
- for i=1, #entries do
- local entry = entries[((i + progress - 1) % #entries) + 1]
- if entry.instruction.id == "create:destination" then
- stations[#stations + 1] = entry.instruction.data.text
- elseif entry.instruction.id == "create:rename" then
- label = entry.instruction.data.text
- end
- end
- name, andName = splitWord(label, " and ")
- if andName == nil then
- name, andName = splitWord(label, " via ")
- end
- print(textutils.serialize(stations))
- print(name)
- print(andName)
Advertisement
Add Comment
Please, Sign In to add comment