1
0
mirror of https://github.com/LDDestroier/CC/ synced 2025-09-02 19:08:00 +00:00

Changed mainPath to optionally be first argument

This commit is contained in:
LDDestroier
2019-05-01 21:32:11 -04:00
committed by GitHub
parent bae6be4fe8
commit 9f8df17943

View File

@@ -1,6 +1,7 @@
local disknet = {} local disknet = {}
local mainPath = "disk/DISKNET" disknet.mainPath = ({...})[1] or "disk/DISKNET"
local limitChannelsToModem = false local limitChannelsToModem = false
local openChannels = {} local openChannels = {}
local yourID = os.getComputerID() local yourID = os.getComputerID()
@@ -78,7 +79,7 @@ disknet.transmit = function(channel, message)
local valid, grr = checkValidChannel(channel) local valid, grr = checkValidChannel(channel)
if valid then if valid then
if disknet.isOpen(channel) then if disknet.isOpen(channel) then
local file = fs.open(fs.combine(mainPath, tostring(channel)), "a") local file = fs.open(fs.combine(disknet.mainPath, tostring(channel)), "a")
file.write(textutils.serialize({ file.write(textutils.serialize({
time = getTime(), time = getTime(),
id = yourID, id = yourID,
@@ -104,15 +105,15 @@ disknet.receive = function(channel)
-- clear files -- clear files
if channel then if channel then
if openChannels[channel] then if openChannels[channel] then
file = fs.open(fs.combine(mainPath, tostring(channel)), "w") file = fs.open(fs.combine(disknet.mainPath, tostring(channel)), "w")
file.close() file.close()
fList[1] = fs.open(fs.combine(mainPath, tostring(channel)), "r") fList[1] = fs.open(fs.combine(disknet.mainPath, tostring(channel)), "r")
end end
else else
for i = 1, #openChannels do for i = 1, #openChannels do
file = fs.open(fs.combine(mainPath, tostring(openChannels[i])), "w") file = fs.open(fs.combine(disknet.mainPath, tostring(openChannels[i])), "w")
file.close() file.close()
fList[i] = fs.open(fs.combine(mainPath, tostring(openChannels[i])), "r") fList[i] = fs.open(fs.combine(disknet.mainPath, tostring(openChannels[i])), "r")
end end
end end