288 posts
Posted 17 November 2015 - 07:04 PM
Been a while :P/>.
But, while making a program, i have been using dofile to access files. Here is an example of my API code:
Note that the API file name is API.lua
function lol()
return lol
end
return API
This file is called program.lua
api = dofile("API.lua")
print(api.lol())
I get the error on program.lua, and its line 2, attempt to call nil ( a nil value ), which means that it is not a valid function that exists. Can you help me?
- Smigger22
EDIT: Solved.
Edited on 17 November 2015 - 06:13 PM
2679 posts
Location
You will never find me, muhahahahahaha
Posted 17 November 2015 - 07:46 PM
api = {}
function api.lol()
return "lol"
end
return api
2427 posts
Location
UK
Posted 17 November 2015 - 09:39 PM
To clarify Creator's post, replace the content of API.lua with his code.
You may want to look at and/or use the
os.loadAPI function, this may allow you to write a function which will load an API as you tried in you OP.
Edited on 17 November 2015 - 08:41 PM
2679 posts
Location
You will never find me, muhahahahahaha
Posted 17 November 2015 - 09:50 PM
To clarify Creator's post, replace the content of API.lua with his code.
You may want to look at and/or use the
os.loadAPI function, this may allow you to write a function which will load an API as you tried in you OP.
smigger22 has been on the forums for a long time, so I thought that this would be self-explanatory.
2427 posts
Location
UK
Posted 18 November 2015 - 12:03 PM
yes, but it's quite possible that other people will read this in future
Edited on 18 November 2015 - 11:03 AM
2679 posts
Location
You will never find me, muhahahahahaha
Posted 18 November 2015 - 01:55 PM
yes, but it's quite possible that other people will read this in future
You are kind of right