Posted 19 March 2013 - 05:16 AM
Hello,
I am stumped at this code. If I individually test the function getPastebin( code, path ) it works fine, but in this context it doesnt for some reason.
It tries to call nil at: "file.write( contents )"
About the table, it has all different codes and paths, but its leading to kind of a secret project. And yes, the getPastebin function is a rip-off of the original pastebin program, I just dont want the text that the program produces :P/>/>
Thank you very much in advance,
Engineer
Edit: I just needed to create the folders before I even wanted to write to them.
I am stumped at this code. If I individually test the function getPastebin( code, path ) it works fine, but in this context it doesnt for some reason.
It tries to call nil at: "file.write( contents )"
local tPB = {
[1] = { "anypastebincode", "path" },
[2] = { "anypastebincode", "path" },
[3] = { "anypastebincode", "path" }
}
function getPastebin( code, path )
local response = http.get(
"http://pastebin.com/raw.php?i=" .. textutils.urlEncode( code )
)
if response then
local contents = response.readAll()
local file = fs.open( path, "w" )
file.write( contents )
file.close()
return true
else
return false
end
end
for i = 1, #tPB do
if getPastebin( tPB[i][1], tPB[i][2] ) then
bar( step ) -- This isnt the problem
else
fail = true
break
end
end
end
About the table, it has all different codes and paths, but its leading to kind of a secret project. And yes, the getPastebin function is a rip-off of the original pastebin program, I just dont want the text that the program produces :P/>/>
Thank you very much in advance,
Engineer
Edit: I just needed to create the folders before I even wanted to write to them.
Edited on 19 March 2013 - 04:50 AM