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

Error with SGCraft interface program, attempt to index ? (a nil value)

Started by Traveling_Man, 30 January 2018 - 04:47 AM
Traveling_Man #1
Posted 30 January 2018 - 05:47 AM
So I'm really new to ComputerCraft and using someone else's code, it's almost several years old but I wanna make it work with my current game. Here is the code https://pastebin.com/whrvAx3e
I'm using 1.7.10, ComputerCraft 1.75, and SGCraft 1.13.3. When I try to run the program it feeds me this error "startup:4: attempt to index ? (a nil value). The orginal creator hasn't updated the code in a couple years and has not respond to my attempts at communication. From other posts I get the feeling one of the objects/variables isn't valid anymore, but I don't know which or even if this is in fact the issue. Anyone know how to fix it?
Bomb Bloke #2
Posted 30 January 2018 - 11:52 AM
The first line is supposed to look for an attached monitor peripheral, build a table of function pointers for dealing with that peripheral, and assign it to "mon".

If it can't find one, though, then "mon" is left as nil - leading to your error on the fourth line, where you attempt to index into it to get the "setBackgroundColor" function pointer. So… do you have an external monitor block connected to your computer?
Traveling_Man #3
Posted 30 January 2018 - 07:58 PM
I do have have a monitor attached. A 3x4 (HxW) one to be specific. Do I need to plug into each individual monitor block? I didn't think so but I could be wrong. I remember I got this code to work a few years ago but I don't remember how.
Bomb Bloke #4
Posted 31 January 2018 - 02:29 AM
You don't need to "plug-in" to more than any one part of the monitor, but if you are using network cable to connect, then you do need to "activate" (right-click) the modem that attaches to the display.
Dog #5
Posted 31 January 2018 - 06:23 AM
…I remember I got this code to work a few years ago but I don't remember how.

IIRC this video goes through the setup.