Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --options
- --naming modes 1=using addition, 2=naming as default
- textName = "table"
- addition = "T"
- namingMode = 1
- --
- version = "1.1.2"
- arg = { ... }
- fullName = shell.getRunningProgram()
- usedName = textName
- path = shell.dir()
- name = string.gsub(fullName, path.."/", "")
- array = {}
- if #arg < 1 then
- print("Usage: "..name.." <path>")
- return
- elseif #arg > 1 then
- print("Usage: "..name.." <path>")
- end
- if not fs.exists(tostring(arg[1])) then
- print("This file doesn't exists")
- return
- end
- --
- function read(path)
- f = fs.open(path, "r")
- local i = 1
- local temp
- while true do
- temp = f.readLine()
- if not temp then break end
- if #temp == 0 then temp = " " end
- array[i] = temp
- i = i + 1
- end
- f.close()
- end
- function write()
- if namingMode == 2 then
- h = fs.open(path.."/"..usedName, "w")
- elseif namingMode == 1 then
- h = fs.open(path.."/"..arg[1]..addition, "w")
- end
- h.write(arg[1].." = {'"..array[1])
- for i = 2, #array do
- h.write("', '"..array[i])
- end
- h.write("'}")
- h.close()
- end
- function selName()
- relay = true
- local a = 1
- while relay do
- if fs.exists(path..usedName) then
- usedName = textName..tostring(a)
- a = a + 1
- else relay = false
- end
- end
- end
- --
- read(path.."/"..arg[1])
- selName()
- write(array)
- f.close()
- h.close()
- print("Ready!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement