Jump to content




window:179:bad argument: string expected, got nil


  • You cannot reply to this topic
2 replies to this topic

#1 DiNuzz__

  • New Members
  • 2 posts

Posted 15 August 2016 - 09:49 PM

I tried to do something like a stupid GUI for CC and while debugging I got this error:

Quote

window:179: bad argument: string expected, got nil
Press any key to continue
I press a random key and then the computer shuts down :-(

PROGRAM: http://pastebin.com/BNEDzDMg
CC Version: 1.79

Please, don't tell me it's a stupid project, I already know.
Thank you :)

#2 Emma

  • Members
  • 216 posts
  • Locationtmpim

Posted 16 August 2016 - 01:31 AM

You store the color information as string literals, then try to set the background/text color with said string literal. Do one of the following:
local desktopbar = {
  "                                                  ",
  colors.black,
  colors.white
}
Or you could do something like this:
local desktopbar = {
  "                                                  ",
  "black",
  "white"
}
-- So use the code you are already using

-- But when you set the colors, do this
term.setBackgroundColor( colors[ name[2] ] )
term.setTextColor( colors[ name[3] ] )


#3 DiNuzz__

  • New Members
  • 2 posts

Posted 16 August 2016 - 10:57 AM

View PostIncinirate, on 16 August 2016 - 01:31 AM, said:

You store the color information as string literals, then try to set the background/text color with said string literal. Do one of the following:
local desktopbar = {
  "												  ",
  colors.black,
  colors.white
}
Or you could do something like this:
local desktopbar = {
  "												  ",
  "black",
  "white"
}
-- So use the code you are already using

-- But when you set the colors, do this
term.setBackgroundColor( colors[ name[2] ] )
term.setTextColor( colors[ name[3] ] )
Oh, thank you!
I didn't remember that, the last time I used computercraft was back in 2014!





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users