Skip to content

Gopmyc/Class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues project_license Email


Logo

Class

A lightweight, flexible, and extensible object-oriented programming (OOP) system for Lua. Provides class creation, inheritance, encapsulation, operator overloading, and utility helpers — all in a single file. Designed for seamless integration in any Lua project, with support for private members, super calls, and robust debugging tools. Inspired by :
Hump.Class

Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Built With
  3. Getting Started
  4. Usage
  5. Roadmap
  6. Contributing
  7. License
  8. Contact
  9. Acknowledgments

About The Project

Class is a self-contained OOP system written in pure Lua. Its goal is to bridge the gap between minimalistic design and powerful features. It is especially handy for environments like Garry's Mod or any Lua-based game/modding framework where OOP-like structures can simplify code organization.

Key Features:

  • 🔧 Dynamic class creation
  • 🧬 Inheritance with super call support
  • 🧱 Public / private members
  • 🔄 Operator overloading
  • 🔍 Debug helpers

🔝

Built With

  • Lua

🔝

Getting Started

Here’s how to set up the project locally.

Prerequisites

You’ll need Lua installed:

Installation

  1. Clone the repo:

    git clone https://github.com/Gopmyc/Class.git
    cd Class
  2. Include class.lua in your Lua project:

    require("class")

Usage

local Class	=	require("class")
local A		=	Class{
    foo	=	function()
		print('foo')
	end,
}

local B		=	Class{
    bar	=	function()
		print('bar')
	end,
}

-- single inheritance
local C		=	Class{__includes = A}
instance	=	C()
instance:foo() -- prints 'foo'
instance:bar() -- error: function not defined

-- multiple inheritance
local D		=	Class{__includes = {A,B}}
instance = D()
instance:foo() -- prints 'foo'
instance:bar() -- prints 'bar'

For more examples, check the documentation.

🔝

Roadmap

  • Basic class + inheritance
  • Private/protected fields
  • Super call support
  • Operator overloading
  • Static fields / class-level attributes
  • Decorators / Mixins
  • Full test suite

Feel free to suggest features via issues.

🔝

Contributing

Contributions make open source better! If you’ve got a fix or idea, fork and PR it.

Steps:

  1. Fork this repo
  2. Create a branch (git checkout -b feature/MyFeature)
  3. Commit (git commit -m 'Add MyFeature')
  4. Push (git push origin feature/MyFeature)
  5. Submit a Pull Request

Top contributors:

🔝

License

Distributed under the MIT License. See LICENSE for more info.

🔝

Contact

Gopmyc 📧 gopmyc.pro@gmail.com 🔗 https://github.com/Gopmyc/Class

🔝

About

A lightweight, flexible, and extensible object-oriented programming (OOP) system for Lua. Provides class creation, inheritance, encapsulation, operator overloading, and utility helpers, all in a single file. Designed for easy integration in any Lua project, with support for private members, super calls, and robust debugging tools.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages