Skip to content

Instantly share code, notes, and snippets.

@greenrift
greenrift / main.lua
Last active December 17, 2015 05:29
main.lua to go along with OOP example blarg.lua
local blarg = require("blarg")
local myblarg = blarg:new()
local mintest = myblarg:minimum(1, 6)
local maxtest = myblarg:maximum(6, 6)
local default = myblarg:toDefault(7)
@greenrift
greenrift / blarg.lua
Last active December 17, 2015 05:18
Example OOP in lua and Corona SDK
local Blarg = {}
local Blarg_mt = {__index = Blarg}
function Blarg:new()
local self = {}
setmetatable( self, Blarg_mt )
self.default = 5
return self
@greenrift
greenrift / lua_tables
Created May 10, 2013 19:11
Lua Table examples
--some examples of Lua tables
--initialize table. very similar to Perl
local mytable = {}
--insert element into table
--Using the insert call appends elements to the end starting at index 1
table.insert(mytable, "Hello")
table.insert(mytable, "World")
@greenrift
greenrift / gist:5556561
Created May 10, 2013 18:53
Lua dynamically typed language example
--Lua is a dynamically typed language
local mystring = "Hello World!" --hello! I'm a string
print(mystring)
--output: Hello World!
mystring = 4.5 --now I'm a float!
print(mystring)
--output: 4.5