| jbob182 |
04-29-2011 10:04 AM |
File Handling Help
I have a couple of questions on file handling. The first is can anyone tell me why I am getting this error:
Quote:
20: bad argument #1 to 'read' (invalid format)
|
for this code:
Code:
function collision(file,p,mapmax)
local collisiontable={};
Collisionmap = io.open(file,"r");
if p.lr == "left" then
Collisionmap:seek("set",p.x);
else
Collisionmap:seek("set",p.x+p.maxx);
end
for i=1,28 do
table.insert(collisiontable,{});
collisiontable[#collisiontable].type = Collisionmap:read("*n");
Collisionmap:seek("cur",mapmax);
end
io.close(Collisionmap);
return collisiontable
end
This was working before but now I do not know why it crashes ("*n") is a proper format.
Second question, i am trying to create a temporary file and this works to an extent:
Code:
tmpcol = assert(io.tmpfile())
tmpcol:close();
If you are wondering why assert is there it is because without assert it prints out the error: if you put it there:
This happens with the adk, if you do not run as administrator ( vista/windows 7).
Does anyone know of a better way to create a temporary file?
|