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

Classy v0.2 - Class system

Started by Thefdjurt, 13 July 2015 - 05:33 AM
Thefdjurt #1
Posted 13 July 2015 - 07:33 AM
This is a (I don't know whether or not this is technically an API so I'll call it a) few functions that allow to make classes (kind of) similar to that of Java's.

pastebin get 5k16MEtY Classy

The GitHub repository (I plan on adding a wiki)

Todo-Make 'define' function for all every environments, supporting specific type and non-specific
-Allow 'extending' or 'extend' function in call

Wow I really need to think of more to write next time, lol.
Edited on 13 July 2015 - 05:33 AM
MKlegoman357 #2
Posted 13 July 2015 - 07:55 AM
Wow I really need to think of more to write next time, lol.

You could start by listing all the features your classes have, and then writing the docs for them.

EDIT: and actually putting the code on GitHub :D/>

EDIT 2: here's a tip: set the __metatable metafield to false, so I could do:


local t = setmetatable({}, { __metatable = false })

local mt = getmetatable(t)

if mt then --# no need for type checking, simply put it as a condition
  print("Got the metatable")
else
  print("Couldn't get the metatable")
end
Edited on 13 July 2015 - 06:03 AM
Thefdjurt #3
Posted 13 July 2015 - 08:01 AM
EDIT: and actually putting the code on GitHub :D/>
I forgot to push the commits XD. Thank you for the feedback!
Thefdjurt #4
Posted 13 July 2015 - 08:25 AM
set the __metatable metafield to false
Fixed in hotfix thank you.
Edited on 13 July 2015 - 06:26 AM