right so I've got an api which refuses to load.
Code: pastebin get kYQqr67d b-client
So basically, os.loadAPI("b-client") returns true but none of the functions are usable. When manually running the program, the API loads and allows usage. Why?
1
api refuses to work
Started by Reinified, May 12 2018 05:16 PM
5 replies to this topic
#1
Posted 12 May 2018 - 05:16 PM
#2
Posted 12 May 2018 - 05:32 PM
try renaming it; os.loadAPI really just loads all the global stuff the file exposes and stores it in a table inside _G. Typing `b-client.someFunction` is not valid Lua though. Another thing you could do is this:
os.loadAPI "b-client" _G["b-client"].someFunction()
#3
Posted 12 May 2018 - 05:41 PM
Thanks, the _G system works.
#4
Posted 13 May 2018 - 05:59 AM
BTW, why don't you use require? Its a lot more controllable that os.loadAPI. You can specify the table in which the api is loaded, and you don't have to have unnecessary globals. You can also name the api files as you want without haveing to do the
local api = _G["api.lua"]thing.
#6
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users