This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TheJebForge's profile picture

fs.readLine( ) help!

Started by TheJebForge, 04 November 2014 - 12:35 PM
TheJebForge #1
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
KingofGamesYami #2
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).
TheJebForge #3
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!
Lyqyd #4
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?
TheJebForge #5
Posted 04 November 2014 - 05:38 PM
It returning ""! Nil! Nothing!

It returns nothing!
TheOddByte #6
Posted 04 November 2014 - 08:23 PM
Try doing this

print( type( dicons ) )
to see if it returns nil or a space character
Lyqyd #7
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?
Bomb Bloke #8
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!
TheJebForge #9
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
Lyqyd #10
Posted 05 November 2014 - 05:39 AM
No, it doesn't. Please actually test things instead of just lying about the results.
TheJebForge #11
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!
Saldor010 #12
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.
TheJebForge #13
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!