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

[Lua] Errors in using paintutils causes the api itself to error

Started by nateracecar5, 23 May 2013 - 05:48 AM
nateracecar5 #1
Posted 23 May 2013 - 07:48 AM
I'm not sure if this is a bug but I am gonna tell it anyway. I was using the paintutils.drawLine() function and typed this code in:

paintutils.drawLine(1,2,w,2,colors.blue)
Because I was in a hurry I forgot to do

w, h = term.getSize()
So when I ran the program I got this error

paintutils: 45:  expected double, got nil.
Is this a bug in the api or computercraft itself not realizing that I didn't do w, h = term.getSize()?
AfterLifeLochie #2
Posted 23 May 2013 - 08:32 AM
While this isn't a bug, paintutils should have probably raised the error back to your code, and not inside the API.

Regardless, this is due to the fact you're passing nil (`w` is undefined) as a parameter to paintutils.drawLine().
Dlcruz129 #3
Posted 23 May 2013 - 10:26 AM
Expected double? I thought Lua only had the number data type.
Cloudy #4
Posted 23 May 2013 - 11:04 AM
Expected double? I thought Lua only had the number data type.

Java side it is handled by doubles.
dan200 #5
Posted 23 May 2013 - 11:17 AM
Expected double? I thought Lua only had the number data type.

Java side it is handled by doubles.

We should of wrote "expected number" in the error message though! Will do a search for instances of that and fix it later