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

Window Error

Started by ebernerd, 25 January 2015 - 03:15 AM
ebernerd #1
Posted 25 January 2015 - 04:15 AM
Hi there.

I am writing a display API for a few programs I am working on.
Problem is I can't even get the first function to work.

Here's the code I have so far:


local display = term
local tX, tY = display.getSize()

function centerAlign(text,y)
  display.setCursorPos(tX/2-#text/2,y)
  display.print(text)
end


Every time I run the function, I get the error window:248: bad argument: double expected, got nil

Can anyone tell me what's up?
Bubba #2
Posted 25 January 2015 - 04:21 AM
What are you passing into centerAlign? My guess is that you aren't passing in a y-value.

Edit: Also, term.print is not a thing
Edited on 25 January 2015 - 03:23 AM
Quintuple Agent #3
Posted 25 January 2015 - 04:23 AM
Also print is not a term function, use write instead.

Edit: Curse you bubba!
Edited on 25 January 2015 - 03:24 AM
ebernerd #4
Posted 25 January 2015 - 04:25 AM
All has been cleared up by the mighty Bubba. Thank you.

Also print is not a term function, use write instead.

Edit: Curse you bubba!

Ah, yes, thank you.