129 posts
Posted 04 November 2014 - 01:35 PM
Im making an OS. But there's an error!
Main File:
...
function loadIcons()
tot = fs.open("wtOS/deskto/tot","r")
dicons = tot.readLine() --<That thing actually returns notting!
tot.close()
dicons = tonumber(dicons)
for i = 1,dicons,1 do
ic = fs.open("wtOS/deskto/sh"..i,"r")
sx[i] = ic.readLine()
sy[i] = ic.readLine()
sip[i] = ic.readLine()
sptp[i] = ic.readLine()
sn[i] = ic.readLine()
ic.close()
end
end
...
(dots - not in code, just showing that piece of code)
wtOS/deskto/tot:
0
And dicons = nil! Whyyy?
Edited on 04 November 2014 - 03:52 PM
3057 posts
Location
United States of America
Posted 04 November 2014 - 03:15 PM
tot.readLine() is returning something that cant be converted into a number, eg "hello". Try adding some prints in to see what it's doing. Also post the files in question (wtOs/deskto/tot).
129 posts
Posted 04 November 2014 - 04:44 PM
tot.readLine() have to return "0"! Look wtOS/deskto/tot thing
But it return nil or something else!
8543 posts
Posted 04 November 2014 - 05:35 PM
What does it return instead? What makes you think it isn't returning "0" if you don't know what it is returning?
129 posts
Posted 04 November 2014 - 05:38 PM
It returning ""! Nil! Nothing!
It returns nothing!
1852 posts
Location
Sweden
Posted 04 November 2014 - 08:23 PM
Try doing this
print( type( dicons ) )
to see if it returns nil or a space character
8543 posts
Posted 04 November 2014 - 09:47 PM
It returning ""! Nil! Nothing!
It returns nothing!
An empty string and nil are two different values. You still didn't answer my other question, what symptoms does the program display to cause you to believe that that function call is returning nil?
7083 posts
Location
Tasmania (AU)
Posted 04 November 2014 - 10:42 PM
tot.readLine() have to return "0"! Look wtOS/deskto/tot thing
But it return nil or something else!
… does that file contain 0 (like you're saying here), or does it contain o (like you're saying in your first post)? Just as nil and "" aren't the same thing, 0 and o aren't the same thing either. You must be specific!
129 posts
Posted 05 November 2014 - 05:31 AM
When I trying print that variable, after tot.readLine(). The print crashes with error string needed, got nil.
Edited on 05 November 2014 - 04:31 AM
8543 posts
Posted 05 November 2014 - 05:39 AM
No, it doesn't. Please actually test things instead of just lying about the results.
129 posts
Posted 05 November 2014 - 01:34 PM
Now nevermind! I discontinued my OS! You must be hear about that! Im making NxOS and it haven't got this error!
598 posts
Location
The United States
Posted 05 November 2014 - 06:51 PM
Now nevermind! I discontinued my OS! You must be hear about that! Im making NxOS and it haven't got this error!
Please, don't make operating systems if you can't understand basic errors such as this one. I don't want to be mean, but your OS probably isn't going to be very good if you don't understand at least the intermediates of Lua fully.
129 posts
Posted 05 November 2014 - 07:27 PM
That been special error! In other script that works fine! I have use it in JebOS, JacOS, ctOS, but in wtOS it bugged! In NxOS its works fine too!