Yep,I tested with a file with a single 1, and it reads it as string (trying to operate with it returns expected number, got string)
I can think of multiple reasons for your problem.
1. You are not saving your text file in the correct format (ANSI) which allocates 1 byte per character. You can check this by simply looking at the filesize of the file. If it truly is just the character "1", then the file should only be 1 byte.
2. You haven't opened the file correctly in lua, be this not using the right functions, or not specifying the right filepath. The correct code for loading the entirety of a file into a string is:
Code:
file = io.open(System.currentDirectory().."/filename.txt",FREAD)
filesize = io.size(file)
str = io.read(file,0,filesize)
io.close(file)
3. You are accessing the wrong string, or using the wrong arguments. Try printing your string with Screen.debugPrint to check if you actually are using the right variable.
4: Assuming the function that's throwing the error is the tonumber line: You're entering a string into the base parameter of tonumber(e [, base]). e must be a string, base must be a number if included.
Last edited by HexZyle,











