Skip to content

Instantly share code, notes, and snippets.

@gazliddon
Created November 1, 2014 14:07
Show Gist options
  • Save gazliddon/23087a9ea481b18f40cc to your computer and use it in GitHub Desktop.
Save gazliddon/23087a9ea481b18f40cc to your computer and use it in GitHub Desktop.
Is This Bad Lua Form?
-- Creating a object and I have a load of action functions that all return self
-- which means I can chain the functions
-- and also chain after initialisation
-- I like the brevity but I'm no Lua expert. Any thoughts? :)
function CippyGame:titleScreen()
local keepGoing = true
local components = {
text = TextWindowComp()
:borders ( { 10, 20 } )
:col ( { 1, 1, 1, 1 } )
:size( 10 )
:center( 100, "AWFUL GENERIC GAME!" )
:col ( { 1,0,1,1 } )
:size( 3 )
:center( 200, "PRESS START" ),
}
local ents = Entity { components = components }
while keepGoing do
local pad = self.game:getControls()
keepGoing = pad.action.pressed == false
ents:update()
self:sleep()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment