Created
November 22, 2015 04:28
-
-
Save bmwalters/b3d01162b0a637829175 to your computer and use it in GitHub Desktop.
converts a lua array to an arnoldc function
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 characters
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