Jump to content




Attempt to call nil on settings API


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

#1 jv110

  • Members
  • 108 posts
  • LocationIn front of my PC

Posted 18 May 2016 - 10: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 by jv110, 22 May 2016 - 02:23 AM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 18 May 2016 - 10: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.

#3 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 18 May 2016 - 11:02 PM

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

#4 jv110

  • Members
  • 108 posts
  • LocationIn front of my PC

Posted 19 May 2016 - 12: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 by jv110, 19 May 2016 - 12:23 AM.


#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 19 May 2016 - 12:58 AM

Full script, please.

#6 jv110

  • Members
  • 108 posts
  • LocationIn front of my PC

Posted 19 May 2016 - 03:44 PM

It's _really_ long, but ok

Should I send the whole built program or just the file it happened in?

Edited by jv110, 19 May 2016 - 03:53 PM.


#7 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 19 May 2016 - 04: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.

#8 jv110

  • Members
  • 108 posts
  • LocationIn front of my PC

Posted 22 May 2016 - 02:20 AM

https://github.com/jv110/Gray
Line 210 of main.lua

Edited by jv110, 22 May 2016 - 02:20 AM.


#9 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 22 May 2016 - 02:47 AM

Line 4:

os.loadAPI("settings")

What's the content of this file?

#10 Waitdev_

  • Members
  • 432 posts
  • LocationAdelaide

Posted 22 May 2016 - 03:23 AM

Make sure that you're not making any typos, it might be the reason it's not working

#11 jv110

  • Members
  • 108 posts
  • LocationIn front of my PC

Posted 22 May 2016 - 04:29 AM

 Bomb Bloke, on 22 May 2016 - 02:47 AM, said:

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.

#12 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 22 May 2016 - 05:14 AM

What do you get if you stick this directly before line 210?:

for key, value in pairs(settings) do print(key) end


#13 jv110

  • Members
  • 108 posts
  • LocationIn front of my PC

Posted 22 May 2016 - 05:56 AM

Posted Image

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:

Posted Image

Actually, I'm an idiot. Found the problem.

Edited by jv110, 22 May 2016 - 05:57 AM.






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users