<filename>:51: attempt to concatenate string and nil
Here's the programs;
Receiver Program
Spoiler
--Updater Recieving Program V1
rednet.open("right")
function progRecieve()
event1, id1, message1 = os.pullEvent()
if event1 == "rednet_message" then
fileNumber = message1
term.clear()
term.setCursorPos(1,1)
print("Number Recieved")
else
end
for q = 1, 8 do
event2, id2, message2 = os.pullEvent()
if event2 == "rednet_message" then
fileName = textutils.unserialize(message2)
print("File Name: "..fileName)
else
end
event3, id3, message3 = os.pullEvent()
if event3 == "rednet_message" then
progTable = {}
progTable = textutils.unserialize(message3)
else
end
writeProg(progTable, tostring(fileName))
end
end
function writeProg(prog, fileWName)
local file = fs.open("TestDir/"..fileWName, "w")
for i = 1, 1 do
file.write(prog)
end
file.close()
fileWName = nil
end
program, fileName = progRecieve()
writeProg(program, fileName)
Sender Program (Aka where all the files are stored)
Spoiler
--Updater Sender V1
rednet.open("right")
function sendProg(progsTable, sendID, fileNames)
rednet.send(1, "8")
sleep(1)
for i = 1, #progsTable do
rednet.send(1, textutils.serialize(fileNames[i]))
sleep(1)
rednet.send(1, textutils.serialize(progsTable[i]))
end
return
end
function convertProg(progs)
progsTable = {}
for i = 1, #progs do
local oFile = fs.open(tostring(progs[i]),'r')
prog = {}
prog = oFile.readAll()
oFile:close()
table.insert(progsTable, prog)
end
progsTable = textutils.serialize(progsTable)
return progsTable
end
function runMain(filesName, saveNames)
progsTable = convertProg(filesName)
sendProgTable = textutils.serialize(progsTable)
sendProg(sendProgTable, 1, saveNames)
end
progLocs = {"/cake", "/can", "/case", "/computer", "/foot", "/krypt", "/mouse", "/notepad", "/pen", "/test", "/test1"}
progNames = {"cake", "can", "case", "computer", "foot", "krypt", "mouse", "notepad", "pen", "test", "test1"}
runMain(progLocs, progNames)
Sorry for the messy weird code that you may have issues reading etc, but there's also an odd bug that I noted, in the receiving program, for debug reasons, I added a clear and a print in a couple of places to tell me where its at.
Well first off, the term.clear() after its meant to receive how many programs will not fire, not sure whats going on there, then after that the line "print("File Name: "..fileName)" prints the number.
This is quite possibly the weirdest code that I have ever made, it also thinks that when you swap out the 8 in the for statement for "fileNumber" it says something like the for statement has no max amount of times it can repeat.
To anyone who can help, thank you and I would be amazed if anyone could figure this out…. It wouldn't just be my emulator would it? o.O
Cheers
Krypt