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

Attempt to call nil on settings API

Started by jv110, 18 May 2016 - 09:42 PM
jv110 #1
Posted 18 May 2016 - 11:42 PM
For some reason, when I run my program, I get this error:


sys:961: attempt to call nil

It's on a settings.load call:


settings.load("system/.settings")

There is nothing disabling the settings API, and the file does exist. It's really frustrating, and it's making me wanna quit.

I can't really just post the code here as it would just spoil everything, but I could PM it or send parts of it.
Edited on 22 May 2016 - 01:23 AM
KingofGamesYami #2
Posted 18 May 2016 - 11:55 PM
The problematic line is probably not that one. Sometimes lua errors are off by one or two lines. To really help you, I do need the full code. If you PM me the code I can help, but it would be most helpful if you can post it here.
Lupus590 #3
Posted 19 May 2016 - 12:02 AM
a debug trick that some people use is to get your program to output to the screen (or a file) to record it's progress, you then know that the error is caused between the last debug message written and the next one which was not written
jv110 #4
Posted 19 May 2016 - 01:21 AM
This is the piece of code it happens in:


  local users = getusers()
  
  if #users == 0 then
	newuser()
	selectusr(getusers()[1], {["logscreen"] = logscreen, ["lockscreenrunning"] = lockscreenrunning})
  else
	settings.load("system/.settings")
	selectusr(settings.get("lastuser", users[1]), {["logscreen"] = logscreen, ["lockscreenrunning"] = lockscreenrunning})
  end
Edited on 18 May 2016 - 11:23 PM
Bomb Bloke #5
Posted 19 May 2016 - 01:58 AM
Full script, please.
jv110 #6
Posted 19 May 2016 - 04:44 PM
It's _really_ long, but ok

Should I send the whole built program or just the file it happened in?
Edited on 19 May 2016 - 02:53 PM
Dragon53535 #7
Posted 19 May 2016 - 05:17 PM
Upload the files to a paste site like Pastebin and give us the links, tell us what file it occured in, and we should be able to see most of the issue.
jv110 #8
Posted 22 May 2016 - 03:20 AM
https://github.com/jv110/Gray
Line 210 of main.lua
Edited on 22 May 2016 - 01:20 AM
Bomb Bloke #9
Posted 22 May 2016 - 03:47 AM
Line 4:

os.loadAPI("settings")

What's the content of this file?
Waitdev_ #10
Posted 22 May 2016 - 04:23 AM
Make sure that you're not making any typos, it might be the reason it's not working
jv110 #11
Posted 22 May 2016 - 05:29 AM
Line 4:

os.loadAPI("settings")

What's the content of this file?

It was just a failed attempt at making this work, probably the settings API wasn't loaded so I tried to load it manually. It gives the same error if I remove that.
Bomb Bloke #12
Posted 22 May 2016 - 06:14 AM
What do you get if you stick this directly before line 210?:

for key, value in pairs(settings) do print(key) end
jv110 #13
Posted 22 May 2016 - 06:56 AM


Weird, I get the full instruction set, including load
I put a read() after it, and when I press enter it gives the same error

EDIT:



Actually, I'm an idiot. Found the problem.
Edited on 22 May 2016 - 04:57 AM