Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- CCLUA prepocessor
- This can be ported to vanilla LUA very simply
- ~Piorjade
- ]]
- local arguments = {...}
- if #arguments ~= 1 then
- print("Usage: prepoc <file> <outputName>")
- end
- local currentLine
- local fileData = "---Processed with LUAPreProc---"
- local file = fs.open(arguments[1], "r")
- repeat
- currentLine = file.readLine()
- if currentLine ~= nil and currentLine:sub(1, 3) == "--#" then
- local command = currentLine:sub(currentLine:find("%b[]"))
- if command == "[include]" then
- local argument = currentLine:sub(14, #currentLine)
- local argumentFile = fs.open(argument, "r")
- print("Including: "..tostring(argument))
- local argumentData = argumentFile.readAll()
- argumentFile.close()
- fileData = fileData.."\n"..argumentData
- end
- elseif currentLine ~= nil then
- fileData = fileData.."\n"..currentLine
- end
- until currentLine == nil
- file.close()
- local file = fs.open(arguments[1], "w")
- file.write(fileData)
- file.close()
Advertisement
Add Comment
Please, Sign In to add comment