doc fixes
This commit is contained in:
parent
6fee9a52fb
commit
804d0cfccb
@ -1,2 +1,3 @@
|
|||||||
# LEEF-class
|
# LEEF-class
|
||||||
implements classes and immutable tables (proxy tables.). Documetation soon :tm:
|
implements classes and immutable tables (proxy tables.).
|
||||||
|
Documentation found at https://luanti-extended-engine-features.github.io/documentation/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--- An instantiatable class to inherit for defining new instantiatble classes classes
|
--- An instantiatable class to inherit for defining new instantiatble classes classes
|
||||||
-- the "base" class. To make a new class call `new_class:inherit(your_new_class)`.
|
-- the "base" class. To make a new class call `new_class:inherit(your_new_class)`.
|
||||||
-- also note that these classes will not have the type "table" but "class".
|
-- Also note that these classes will not have the type `table` but instead `class` when `type(object)` is called.
|
||||||
--
|
--
|
||||||
-- @classmod new_class
|
-- @classmod new_class
|
||||||
local objects = {}
|
local objects = {}
|
||||||
@ -58,7 +58,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- creates an instance of the base class. Calls all constructors in the chain with def.instance=true
|
--- creates an instance of the base class. Calls all constructors in the chain with def.instance=true
|
||||||
-- @return def field for the new instance of the class. If fields are not present they will refer to the base class's fields (if present in the base class).
|
-- @param def field for the new instance of the class. If fields are not present they will refer to the base class's fields (if present in the base class).
|
||||||
|
-- @return self a new instance of the class.
|
||||||
-- @function new
|
-- @function new
|
||||||
function leef.class.new_class:new(def)
|
function leef.class.new_class:new(def)
|
||||||
--if not def then def = {} else def = table.shallow_copy(def) end
|
--if not def then def = {} else def = table.shallow_copy(def) end
|
||||||
@ -73,6 +74,12 @@ function leef.class.new_class:new(def)
|
|||||||
self.construct(def)
|
self.construct(def)
|
||||||
return def
|
return def
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (for printing) dumps the variables of this class
|
||||||
|
-- @param self
|
||||||
|
-- @tparam bool dump_classes whether to also print/dump classes.
|
||||||
|
-- @treturn string
|
||||||
|
-- @function dump
|
||||||
function leef.class.new_class:dump(dump_classes)
|
function leef.class.new_class:dump(dump_classes)
|
||||||
local str = "{"
|
local str = "{"
|
||||||
for i, v in pairs(self) do
|
for i, v in pairs(self) do
|
||||||
@ -96,6 +103,7 @@ function leef.class.new_class:dump(dump_classes)
|
|||||||
end
|
end
|
||||||
return str.."\n}"
|
return str.."\n}"
|
||||||
end
|
end
|
||||||
|
|
||||||
local old_type = type
|
local old_type = type
|
||||||
function type(a, ...)
|
function type(a, ...)
|
||||||
if objects[a] then return "class" end
|
if objects[a] then return "class" end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user