58 posts
Posted 28 February 2014 - 01:06 PM
I'm making an API and I want it to print a Version Line on being loaded. is there any way to do this without it being called in the program?
1281 posts
Posted 28 February 2014 - 01:08 PM
Anything in the API is ran when it's loaded, just in it's own environment table, so just put a print at the top of it.
58 posts
Posted 28 February 2014 - 01:15 PM
I don't quite get what you mean. Where do I need to put the print?
1140 posts
Location
Kaunas, Lithuania
Posted 28 February 2014 - 03:14 PM
You can put it anywhere outside of any functions.
The way API loading in ComputerCraft works is os.loadAPI runs an API just like a normal program, then takes all global variables left after run and puts it into a global table.
Something like this would work:
--// Test API
local version = "1.0.2"
function test ()
...
end
print(version)
--// Test program
os.loadAPI("test") -->> prints '1.0.2'
58 posts
Posted 28 February 2014 - 03:33 PM
Oh right thanks