For me stat on non-existing file broke the script and an error was displayed. Something like bad pointer to a table - I don't remember ('stat' is the element of the table 'os'). Fopen method works well
Then you did something wrong, or the port you are using is horribly broken. My guess would be you tried to use the return value of stat as a table without checking whether it was nil or not first.
To check if something exists called 'A/FOO' you can just use
if os.stat('A/FOO') then
...-- foo exists, might be a file or directory or volume label!
If you want to check that it's a file, then you'd do something like
st = os.stat('A/FOO')
if st and st.is_file then
... -- foo is a file
If you leave out the st before the and, you will be trying to use nil as a table and generate an error.
FWIW, for things like get_input(), you might find using ipairs clearer (and less typing)
for i,key in ipairs(REPEATABLE_KEYS_TABLE) do
if is_pressed(key) then
PRESSED_KEY=key
end
end
Sorry for the OT, and nice work on the script