![](https://secure.gravatar.com/avatar/b0886ce6acd8fbd59953222285cac78b.jpg?s=120&d=mm&r=g)
Hi All, Getting Closer I asked:
2) While I’m having good luck with paths, colors are causing trouble. In the data set the color information is in strings with French names of the color, like “rouge.” If I hand this string to MetaPost, MetaPost doesn’t expand it into a color. It does work if it is a native color, like “red,” but not if it is a defined color and not if the color is in a Lua variable. Any suggestions?
Aditya suggested:
\definecolor[rouge][red] should work. A better option will be use color palettes.
This solves my problem of translating French colors into English, but not the problem of passing colors from Lua to MetaPost. If the string giving the color name is in a variable, it doesn’t go through. A path in a variable works. I’ve reduced my MWE below – no French, no MPinclusions, no new colors. Both pie slices should be red, but one is black. Any ideas on getting the color “red” passed from Lua to MetaPost when mycolor=“red”? Thanks! Gavin \startluacode mypath = {{0,0}, {2,0,0,0,2,0.5}, {1.6,1.2,1.9,0.8}, cycle = true} mycolor = “red” --% Data files are read by Lua, so the color of each object will be a string, like "red". function mp.getpath() --% Is there a way for the MetaPost code to grab the path directly from the table? mp.inject.path(mypath) end function mp.getred() --% Returning a string works. mp.inject.string("red") end function mp.getcolor() --% Putting the string in a variable does not work. mp.inject.string(mycolor) end \stopluacode \starttext \startMPpage fill lua.mp.getpath() scaled 2.5cm withcolor lua.mp.getred(); % Returning a string works. fill lua.mp.getpath() scaled 2.5cm shifted (0, -4cm) withcolor lua.mp.getcolor(); % Putting the string in a variable does not work. \stopMPpage \stoptext