android
  #21  
Old 01-04-2010, 04:43 PM
bzdbbb's Avatar
bzdbbb bzdbbb is offline
X-Fi2 Development Moderator
 
Join Date: Dec 2009
Location: Gloucestershire, UK
Posts: 94
Default

I read those articles and wrote the following code. I don't understand why it doesn't work..

Code:
-- get the previous highscores
    file = io.open("highscore.txt", "r");
    highscore = file:read("*n");
    file:close();
and then later

Code:
text.draw(304,48,tostring(highscore));
The code works fine without this addition. What's wrong with it?

Thank you in advance
Reply With Quote

Advertisement [Remove Advertisement]

  #22  
Old 01-06-2010, 06:11 AM
tr00st tr00st is offline
Junior Member
 
Join Date: Jan 2010
Location: Suffolk, UK
Posts: 4
Default

Hi,

Not sure exactly what the problem is... Does this give an "Error Occured" error, rather than just not working as expected? If so, you might want to try catching the error using pcall. You might use something like:

Code:
function wrappedCode(argument)
  -- Your code here, instead of the error line
  error "This would not be here if you had some code!"
end
success, message = pcall(wrappedCode, "String as argument")
After running, that would set the variable success to true when the code executed fine, or false if there's an error, as well as setting "message" to any error message that was given.

Hope that helps!
Reply With Quote

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 07:30 AM.