Revisions
-
Bradshaw revised this gist
Sep 8, 2013 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ -- Files are like functions in lua, except they're only meant to be calles once so you're better off doing what I suggested in my gist local health = 100 -- This is local to the whole file -- class wasn't useful function getHealth() return health -- This returns the value, so health is closed to the file, but can be "read" with this function end -
Bradshaw revised this gist
Sep 8, 2013 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,11 @@ local class = {} -- Since you're returning this at the end, I assume you want it local to the file -- Problem is, you can only have this file run once, or otherwise remove the "local" but then you're redefining the values each time you call the file (with an ugly dofile no less) local health -- This is local to the whole file function class.getHealth() -- Renamed to avoid confusing, replaced ob:meth() with ob.meth() syntax because that's not how closures are used return health -- This returns the value, so health is closed to the file, but can be "read" with this function end return class -
hugodes created this gist
Sep 8, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ class = {} local health function class:health() return health end return class