View difference between Paste ID: vG4vjJWr and HUVAvmcZ
SHOW: | | - or go back to the newest paste.
1
function peripheral.find(pType)
2-
  pList = {}
2+
	pList = {}
3-
  for _,pName in pairs(peripheral.getNames()) do
3+
	for _,pName in pairs(peripheral.getNames()) do
4-
    if peripheral.getType(pName) == pType then
4+
		if peripheral.getType(pName) == pType then
5-
      table.insert(pList, peripheral.wrap(pName))
5+
			table.insert(pList, peripheral.wrap(pName))
6-
    end
6+
		end
7-
  end
7+
	end
8-
  return unpack(pList)
8+
	return unpack(pList)
9
end
10
local sign = peripheral.find("sign")
11-
local colorSymbol = ""
11+
local colorSymbol = string.char(194) .. string.char(167)
12
13-
file = fs.open("colorSymbol","wb")
13+
function saveSign(file_name)
14-
file.write(194)
14+
	local file = fs.open(file_name, "w")
15-
file.write(167)
15+
	for y=1, 4 do
16-
file.close()
16+
		file.writeLine( sign.getLine(y) )
17
	end
18-
file = fs.open("colorSymbol", "r")
18+
	file.close()
19-
colorSymbol = file.readAll()
19+
20-
file.close()
20+
21
function pasteSign(file_name)
22
	local file = fs.open(file_name, "r")
23
	for y=1, 4 do
24-
args = {...}
24+
		txt[y] = sign.setLine(y, file.readLine() or "")
25
	end
26-
if args[1] and args[2] and tonumber(args[1]) then  
26+
	file.close()
27-
  local line = tonumber(args[1])
27+
28-
  local text = ""
28+
29-
  
29+
local args = {...}
30-
  for i=2, #args, 1 do
30+
if args[1] then  
31-
    text = text .. args[i]
31+
	local line = tonumber(args[1])
32-
    if args[i+1] then
32+
	if line and args[2] then
33-
       text = text .. " "
33+
		local text = ""
34-
    end
34+
		for i=2, #args, 1 do
35-
  end
35+
			text = text .. args[i]
36-
  
36+
			if args[i+1] then
37-
  text = text:gsub("&", colorSymbol)
37+
				text = text .. " "
38-
  sign.setLine(line,text)
38+
			end
39-
  return
39+
		end
40
		text = text:gsub("&", colorSymbol)
41
		sign.setLine(line,text)
42-
print("Usage: sign <line> <text>")
42+
		return
43
	end
44
	
45
	if args[1] == "save" then
46
		saveSign(args[2] or "savedSign")
47
		return
48
	end
49
	
50
	if args[1] == "paste" then
51
		pasteSign(args[2] or "savedSign")
52
		return
53
	end
54
end
55
56
print("Usage 1: sign <line> <text>")
57
print("Usage 2: sign save <filename>")
58
print("Usage 3: sign paste <filename>")