tlf30 0 Posted February 24, 2015 Share Posted February 24, 2015 Hello, I am somewhat new to openComputers and need a little help with how libraries work. I have read the library tutorial and that was very helpful. My library is structured like so local lib = {} function lib.fun1() { print("It worked!") } return lib I placed the lib in the /lib folder under the name libname.lua, and made a program that used the lib like so: local l0 = require("libname") l0.fun1() But I am getting the error: /lib/test.lua:2: attempt to index local 'libname' (a boolean value) I am not sure what I am doing wrong and would love some help. Thanks, tlf30 Quote Link to post Share on other sites
Sangar 92 Posted February 24, 2015 Share Posted February 24, 2015 function lib.fun1() { print("It worked!") } That's not valid Lua. So it'll fail loading the library - you can use local lib, reason = require("libname") if not lib then print(reason) return end To print the error and "soft fail", or local lib = assert(require("libname")) to generate an error if the lib fails to load. You may need to reboot when changing the library or manually unload it (package.loaded["libname"] = nil) or the system will re-use a cached version. Quote Link to post Share on other sites
MaximilianVINCENT 8 Posted February 24, 2015 Share Posted February 24, 2015 I believe function lib.fun1() print("It worked!") end is correct. Quote Link to post Share on other sites
tlf30 0 Posted February 28, 2015 Author Share Posted February 28, 2015 Sorry, I do a lot of C programming and get confused. Rebooting the computer fixed the problem, thank you. Quote Link to post Share on other sites