Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Quantum Link Linker by Totoro --
- -- Version 2. All right reserved! --
- local fs = require('filesystem')
- local com = require('component')
- local serial = require('serialization')
- local modem = com.modem
- local proxy = ...
- fs.mount(proxy, '/linker')
- local users = {}
- function loadUsers()
- if fs.exists("linker/userlist.txt") then
- local file = io.open("linker/userlist.txt", "r")
- local data = file:read("*a")
- users = serial.unserialize(data)
- file:close()
- if users == nil then users = {} end
- end
- end
- function saveUsers()
- local file = io.open("linker/userlist.txt", "w")
- local data = serial.serialize(users)
- file:write(data)
- file:close()
- end
- print("[ Quantum Linker ]")
- print("get - получить адрес, set - установить таблицу, clear - очистить таблицу")
- local command = io.read()
- if command == 'get' then
- if modem == nil then
- print("Отсутствует сетевая плата. Этот компьютер не может быть клиентом.")
- else
- print("Описание (можно опустить): ")
- desc = io.read()
- loadUsers()
- table.insert(users, {address = modem.address, description = desc})
- saveUsers()
- print("Готово. Адрес в таблице.")
- end
- elseif command == 'set' then
- if fs.exists("linker/userlist.txt") then
- fs.copy("linker/userlist.txt", "userlist.txt")
- print("Готово. Новая таблица установлена.")
- end
- elseif command == 'clear' then
- if fs.exists("linker/userlist.txt") then
- fs.remove("linker/userlist.txt")
- print("Готово. Таблица удалена.")
- end
- else
- print("'"..command.."' - неверная команда.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement