Skip to content

Instantly share code, notes, and snippets.

@vjandrea
Last active September 9, 2018 15:51
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 vjandrea/2a6c8e6d585444e78877247cfb6e10ad to your computer and use it in GitHub Desktop.
Save vjandrea/2a6c8e6d585444e78877247cfb6e10ad to your computer and use it in GitHub Desktop.
LUA Quote escaping in grandma2
--[[
I am struggling to find the best way to nest quotes while developing grandma2 plugins in LUA
This example shows the best solution i've found so far (ESCAPED SiNGLE QUOTES), but unfortunately
the command line doesn't like single quotes either. Any suggestion?
--]]
function quote_escaping_example()
gma.echo("Quote escaping example")
gma.cmd('Store Sequence 1.1 "QUOTE ESCAPING"');
-- using escaped single quotes saves correctly the command but it won't work when triggered
gma.cmd('Store Sequence 1.1 Cue 1 /o /nc');
gma.cmd('Label Sequence 1.1 Cue 1 "ESCAPED SINGLE QUOTES"')
gma.cmd('Assign Sequence 1.1 Cue 1 /cmd="Assign Root \'Effects\'.\'Global\'.1 /Groups=4"');
-- while escaped double quotes don't work, the command gets executed immediately and not stored in the cue
gma.cmd("Store Sequence 1.1 Cue 2 /o /nc");
gma.cmd("Label Sequence 1.1 Cue 2 'ESCAPED DOUBLE QUOTES'")
gma.cmd("Assign Sequence 1.1 Cue 2 /cmd='Assign Root \"Effects\".\"Global\".1 /Groups=4'");
end
return quote_escaping_example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment