What is Objective Lua?
Objective Lua is a programming language that implements class support in Lua for Love2D without modifying vanilla Lua.
Implementation
It is fairly easy, just implement this snippet of code in the first line of your project code:
Code: Select all
main = require "olua.lua"
Example
Let's start with main.lua file:
Code: Select all
main = require "olua.lua"
function love.update( dt )
main:update( dt )
end
function love.draw()
main:draw()
end
But remember that all classes need to be in classes folder inside your project folder.
classes/Main.olua:
Code: Select all
class Main
function Main()
self.width = 32
self.height = 32
self.x = 100
self.y = 200
end
function update()
end
function draw()
love.graphics.rectangle( "fill", self.x, self.y, self.width, self.height )
end
end
Download and more Information
Added new keywords: class, inherits, new, instanceof
SublimeText support with Love2D!
You can download the project in my GitHub repo here. Also, look around, read a bit, there is more useful information in my repository! And explained more in-depth!
Images
An example program is in the Github repository!
Releases
Version 1.0 - Initial release.
Version 2.0 - Parser overhaul.
Version 2.1 - Additional Math Operation Support.
Version 2.2 - Bug Fixes.
Version 2.3 - Bug Fixes with math operations in classes.
Feedback is appreciated.
Regards,
Laurynas.