Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 28/03/2016
- --Last update: 26/05/2016
- --[[ Notes:
- Nenhuma das funções poderão ser usadas no Transformice
- execute.getFile
- Does:
- Retorna as coisas do arquivo
- Args:
- file --> Nome do arquivo (String)
- format --> Formato de coleta
- *n --> Retorna o primeiro número do arquivo
- *a --> Lê o arquivo por completo
- *l/*L --> A primeira linha
- number --> Lê de 0 até número (Deve ser int)
- execute.editFile
- Does:
- Edita algo no arquivo
- Args:
- file --> Nome do arquivo (String)
- format --> Formato de edição
- w --> Modo escrita
- a --> Modo de adição
- r+ --> Modo de atualização (Não apaga tudo)
- w+ --> Modo de atualização (Apaga tudo)
- a+ --> Modo de adição no fim do arquivo
- edition --> Uma string com todas as informações para a edição
- ]]--
- execute={}
- execute.getFile=function(file,format)
- file = assert(io.open(file,"r"),"The file "..file.." does not exist or you have not access")
- local formatModes = [[ Formats
- "*n" -> Returns the first number;
- "*a" -> Reads all the file;
- "*l/*L" -> First line;
- number -> Reads from 0 'till number (Must be int)
- ]]
- if format~="*n" and format~="*a" and format~="*l" and format~="*L" and type(format)~="number" then error(formatModes) end
- format = format or "*a"
- local _file = file:read(format)
- file:close()
- return _file
- end
- execute.editFile=function(file,format,edition)
- if edition == nil then error("Edition needs a value") end
- if format == "r" then error("Format must be a edition mode") end
- local formatModes = [[ Formats
- "r" -> Read; --You cant use this one here.
- "w" -> Write mode;
- "a" -> Add mode;
- "r+" -> Att mode (Do not erase everything);
- "w+" -> Att mode (Erase everything);
- "a+" -> Add mode in the end of the file
- ]]
- if format ~= "w" and format ~= "a" and format ~= "r+" and format ~= "w+" and format ~= "a+" then error(formatModes) end
- file = assert(io.open(file,format),"The file "..file.." does not exist or you have not access")
- file:write(edition);file:flush();file:close()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement