Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function peripheral.find(pType)
- pList = {}
- for _,pName in pairs(peripheral.getNames()) do
- if peripheral.getType(pName) == pType then
- table.insert(pList, peripheral.wrap(pName))
- end
- end
- return unpack(pList)
- end
- local sign = peripheral.find("sign")
- local colorSymbol = string.char(194) .. string.char(167)
- function saveSign(file_name)
- local file = fs.open(file_name, "w")
- for y=1, 4 do
- file.writeLine( sign.getLine(y) )
- end
- file.close()
- end
- function pasteSign(file_name)
- local file = fs.open(file_name, "r")
- for y=1, 4 do
- txt[y] = sign.setLine(y, file.readLine() or "")
- end
- file.close()
- end
- local args = {...}
- if args[1] then
- local line = tonumber(args[1])
- if line and args[2] then
- local text = ""
- for i=2, #args, 1 do
- text = text .. args[i]
- if args[i+1] then
- text = text .. " "
- end
- end
- text = text:gsub("&", colorSymbol)
- sign.setLine(line,text)
- return
- end
- if args[1] == "save" then
- saveSign(args[2] or "savedSign")
- return
- end
- if args[1] == "paste" then
- pasteSign(args[2] or "savedSign")
- return
- end
- end
- print("Usage 1: sign <line> <text>")
- print("Usage 2: sign save <filename>")
- print("Usage 3: sign paste <filename>")
Add Comment
Please, Sign In to add comment