ComputerCraft Archive

IOFile

computer utility Caitlin-Sykes github

Description

-----------------------------------------------------------------------------

Installation

Copy one of these commands into your ComputerCraft terminal:

wget:wget https://raw.githubusercontent.com/Caitlin-Sykes/ComputerCraft-Scripts/main/PlayerLog/IOFile.lua iofile
Archive:wget https://cc.shobie.xyz/cc/get/gh-Caitlin-Sykes-ComputerCraft-Scripts-playerlog-iofile iofile
Quick Install: wget https://cc.shobie.xyz/cc/get/gh-Caitlin-Sykes-ComputerCraft-Scripts-playerlog-iofile IOFile

Usage

Run: IOFile

Tags

none

Source

View Original Source

Code Preview

-- -----------------------------------------------------------------------------
-- I/O Stuff
-- -----------------------------------------------------------------------------
-- Opens a file in append mode
function OpenFile()
    return fs.open(PATH, "a")
end

-- Closes a file
function CloseFile(file)
    file.close()                                                              
end

-- Writes to a file
function WriteFile(msg)
    file = OpenFile()
    file.writeLine(msg) 
    CloseFile(file)
end


-- -----------------------------------------------------------------------------
-- I/O Stuff
-- -----------------------------------------------------------------------------

-- Path to logging directory
PATH = "/logger/log.txt"