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

Attempt To Perform Arithmetic __add On Nil And Number?

Started by LDShadowLord, 26 October 2013 - 07:04 AM
LDShadowLord #1
Posted 26 October 2013 - 09:04 AM
I am confused by this error. I have never encountered it before. I think I know what the problem is, i'm making a printing api but i'm using old code scraped from one of my computer API's.
Here is the code:
(p is the printer peripheral)

function lPrint(text)
  p.write(text)
  inc()
  p.setCursorPos(1,cons)
end

function cPrint(text)
  getInf()
  term.setCursorPos(math.ceil((vw + 1)/2 - text:len()/2), cons)    <--Line 59 Errors
  lPrint(text)
end

function rPrint(text)
  getInf()
  term.setCursorPos(vw - text:len() - 1, cons)
  lPrint(text)
end

EDIT: Just realised I never included the offending line. Fixed.
sens #2
Posted 26 October 2013 - 09:58 AM
Where is "vw" set?
Engineer #3
Posted 26 October 2013 - 10:07 AM
Where is "vw" set?
EDIT: Just realised I never included the offending line. Fixed.

Sens, dont you ever read complete posts? If he said it has been fixed, it has been fixed. However for the OP, you always must include your complete code!
LDShadowLord #4
Posted 26 October 2013 - 10:21 AM
I managed to find a workaround, and Engineer, the reason I neglected to do so was because this was meant to be a surprise for a friend (don't ask, he's weird). But I will consider that in the future. Thankyou.
sens #5
Posted 26 October 2013 - 10:25 AM
Sens, dont you ever read complete posts?
No post is complete till I've responded to it :P/>

But seriously, I thought he meant he fixed the post by pointing out the offending line with "<–Line 59 Errors". I didn't realize he fixed the issue.
LDShadowLord #6
Posted 26 October 2013 - 05:05 PM
Sens, dont you ever read complete posts?
No post is complete till I've responded to it :P/>

But seriously, I thought he meant he fixed the post by pointing out the offending line with "<–Line 59 Errors". I didn't realize he fixed the issue.

That is what I meant. Anyway, doesn't matter. I fixed the math :)/>