Skip to content

Instantly share code, notes, and snippets.

@bmwalters
Created November 22, 2015 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmwalters/b3d01162b0a637829175 to your computer and use it in GitHub Desktop.
Save bmwalters/b3d01162b0a637829175 to your computer and use it in GitHub Desktop.
converts a lua array to an arnoldc function
local template_start = [[
LISTEN TO ME VERY CAREFULLY %s
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE key
GIVE THESE PEOPLE AIR
HEY CHRISTMAS TREE val
YOU SET US UP 0
HEY CHRISTMAS TREE isKeyEqualToOurCurrentValue
YOU SET US UP @I LIED
]]
local template_end = [[
I'LL BE BACK val
HASTA LA VISTA, BABY
]]
local template_middle = [[
GET TO THE CHOPPER isKeyEqualToOurCurrentValue
HERE IS MY INVITATION key
YOU ARE NOT YOU YOU ARE ME %d
ENOUGH TALK
BECAUSE I'M GOING TO SAY PLEASE isKeyEqualToOurCurrentValue
GET TO THE CHOPPER val
HERE IS MY INVITATION %d
ENOUGH TALK
YOU HAVE NO RESPECT FOR LOGIC
]]
local function makemiddle(key, val)
return string.format(template_middle, key, val)
end
local function array2arnoldcfunc(name, array)
local code = string.format(template_start, name)
for k, v in pairs(array) do
code = code .. makemiddle(k, v)
end
code = code .. template_end
return code
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment