summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid McMackins II <contact@mcmackins.org>2018-05-19 08:16:48 -0500
committerDavid McMackins II <contact@mcmackins.org>2018-05-19 08:16:48 -0500
commitf9cbe3cc5f1867f128015364ce41cab909f93a84 (patch)
treeee9783e55452494ea9d4086b5fe1d263f5d1d470
parent583708d7679d985efd8819c7394f8a181adc9b4c (diff)
Add functionize
-rw-r--r--util.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/util.lua b/util.lua
index 3f1c159..5f4b700 100644
--- a/util.lua
+++ b/util.lua
@@ -1,6 +1,6 @@
--
-- Agario Checkers - Checkers-like game with inspiration from agar.io
--- Copyright (C) 2017 Delwink, LLC
+-- Copyright (C) 2017-2018 Delwink, LLC
--
-- Redistributions, modified or unmodified, in whole or in part, must retain
-- applicable copyright or other legal privilege notices, these conditions, and
@@ -36,6 +36,14 @@
-- OF OR OTHER DEALINGS IN THE WORK.
--
+function functionize(v)
+ if type(v) ~= 'function' then
+ return function(self) return v end
+ end
+
+ return v
+end
+
function string:startswith(pattern)
return self:sub(1, pattern:len()) == pattern
end