-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Features: - Add DISK API: functions for file manipulation - Add speaker.print API (Print your message to the ingame chat log) Bugfixes: - Fixed os.require API
- Loading branch information
Showing
8 changed files
with
367 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require("logic.computer") | ||
|
||
table.insert(computer.apis,{ | ||
name = "disk", | ||
description = "The DISK API provides functions for file manipulation", | ||
entities = nil, | ||
prototype = { | ||
-- Public methods | ||
readFile = { | ||
"disk.readFile(filepath) - Writes the value of each of its arguments to the file.", | ||
function(self, filepath) | ||
return self.__readFile(filepath) | ||
end | ||
}, | ||
writeFile = { | ||
"disk.writeFile(filepath, ...) - Truncate the file and write the value of each of its arguments.", | ||
function(self, filepath, ...) | ||
return self.__writeFile(filepath, ...) | ||
end | ||
}, | ||
appendFile = { | ||
"disk.appendFile(filepath, ...) - Append the value of each of its arguments to the file.", | ||
function(self, filepath, ...) | ||
local data = "" | ||
if self.__fileExist(filepath) then | ||
data = self.__readFile(filepath) | ||
end | ||
return self.__writeFile(filepath, data, ...) | ||
end | ||
}, | ||
removeFile = { | ||
"disk.removeFile(filepath) - Append the value of each of its arguments to the file.", | ||
function(self, filepath) | ||
if self.__fileExist(filepath) then | ||
self.__removeFile(filepath) | ||
end | ||
end | ||
}, | ||
fileExist = { | ||
"disk.fileExist(filepath) - Return true if given file exist.", | ||
function(self, filepath) | ||
return self.__fileExist(filepath) | ||
end | ||
}, | ||
|
||
-- Alias | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.