User Tools

Site Tools


mod-functions:io

IO functions

fileExists

Checks if a file exists in the mod directory

local success = myMod:fileExists(filePath)

Parameters:

  • filePath (string): the relative path to the file, inside the mod directory

Return:

  • success (boolean): true if the file is inside the mod directory and exists, false otherwise

directoryExists

Checks if a directory exists in the mod directory

local success = myMod:directoryExists(directoryPath)

Parameters:

  • filePath (string): the relative path to the directory, inside the mod directory

Return:

  • success (boolean): true if the directory is inside the mod directory and exists, false otherwise

readFileAsString

Reads a whole file as a single string

local success, content = myMod:readFileAsString(filePath)

Parameters:

  • filePath (string): the relative path to the file, inside the mod directory

Return:

  • success (boolean): true if the file exists and it could be read, false otherwise
  • content (string): the file content

writeFileAsString

Writes a string in a file

local success = myMod:writeFileAsString(filePath, fileContent)

Parameters:

  • filePath (string): the relative path to the file, inside the mod directory
  • fileContent (string): the content to write in the file

Return:

  • success (boolean): true if the file writing succeeded, false otherwise

createDirectory

Creates a directory in the mod directory

local success = myMod:createDirectory(directoryPath)

Parameters:

  • directoryPath (string): the relative path to the directory, inside the mod directory

Return:

  • success (boolean): true if the directory creation succeeded, false otherwise

moveFile

Moves/renames a file or directory within the mod directory

local success = myMod:moveFile(sourcePath, destinationPath)

Parameters:

  • sourcePath (string): the relative path to the file to move/rename, inside the mod directory
  • destinationPath (string): the relative path to the destination, inside the mod directory

Return:

  • success (boolean): true if the moving/renaming succeeded, false otherwise

deleteFile

Deletes a file within the mod directory

local success = myMod:deleteFile(filePath)

Parameters:

  • filePath (string): the relative path to the file to delete, inside the mod directory

Return:

  • success (boolean): true if the file was successfully deleted, false otherwise

deleteDirectory

Deletes a directory and all its content within the mod directory

local success = myMod:deleteDirectory(directoryPath)

Parameters:

  • directoryPath (string): the relative path to the directory to delete, inside the mod directory

Return:

  • success (boolean): true if the directory was successfully deleted, false otherwise
mod-functions/io.txt · Last modified: 2019/05/29 11:13 (external edit)