android
  #1  
Old 04-29-2011, 10:04 AM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default 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:
Quote:
tmpcol is a nil value
if you put it there:
Quote:
Permission is denied
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?
Reply With Quote

Advertisement [Remove Advertisement]

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:16 PM.