This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
wilcomega's profile picture

Fully working Class api system, example incuded

Started by wilcomega, 13 January 2013 - 04:24 AM
wilcomega #1
Posted 13 January 2013 - 05:24 AM
hello everyone,

today i made an api that allows you to make instances out of files. and interact with them like you do with apis.
it had 2 functions:

class.load( file, on_instance ) --loads a file like an api. the file is also the name. on_instance is the name of the function that will be executed when a new instance it made.
class.instace( name ) --makes a new instance of that class and returns a table containing the class.

that is it. this is maybe usefull for exsensive OS's that have alot of files. if you happend to be a maker of one of those os's i reccomend you checking out my archive program. to send all the files in one package.
this may also be usefull for big games that use OOP and want some organasation( my english ).

download:
http://pastebin.com/5hgJMp4w

here is an example:
myclass:

function init( )
print "made a new instace of myclass"
end
function test( )
print "executed test function in the instace"
end
screenshot of what i did:
Spoiler

please give me some feedback on this.

BTW:
the reason i posted it in the programs section not the apis section is that here it will get way more attention. and that is what i want
wilcomega #2
Posted 13 January 2013 - 05:38 AM
updated with download link :P/>