Embedding MSL into scripting languages Like Lua
Posted: 2012-12-27T05:05:47-07:00
Hi,
I'm currently messing around with MSL inside a Lua scripting engine of an application that is compiled for OSX, Linux and Windows which is the reason for me to try MSL:requires the least hassle and allows running conjure out-of-the-box from a custom location.
The Lua scripting engine has a document engine that allows for writing output in XML code, but it has its limitations.
One of the limitations is that using the same tags in an existing (sub)node is prohibited. e.g.
is not tolerated and the last operationblock for <image> will overwrite the first one completely.
Also the order in which parameters are written are not the same order as i instruct the document creator to generate it.
So i'm trying to figure out how flexible MSL really is in interpreting the xml stuff and if parameters are also allowed to be served as nodes.
This snippet of Lua code:
Generates this block of xml:
I have to create a group because the doc_version parameter is always submitted to the parent tag, i can't avoid the API from inserting it. (is there a way to allow Conjure to ignore unknown parameters for critical tags?)
What i'm trying to aim for here is that MSL has a great potential for usage in these kind of generic scripting languages (tool applications that use it, games that use a scripting language and allows third party tools to run) as a nice library add-on.
Are there any plans to make MSL more flexible, scan the code for tags and/or parameters regardless of their order yet ignore what it doesn't know?
The current way the XML document API in my tool works is, well unusable for MSL now, so i have to rewrite this XML document management myself to be able to circumvent the limitations and allow adding parameters inside the node tags.
The other thing i need to know is the minimum required files for conjure / convert to work on any platform. The Windows autonome zip package is a whopping 45MB, i doubt i need everything to make this work but i also don't know what i can exactly leave out.
I'm currently messing around with MSL inside a Lua scripting engine of an application that is compiled for OSX, Linux and Windows which is the reason for me to try MSL:requires the least hassle and allows running conjure out-of-the-box from a custom location.
The Lua scripting engine has a document engine that allows for writing output in XML code, but it has its limitations.
One of the limitations is that using the same tags in an existing (sub)node is prohibited. e.g.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<group>
<image>
....
</image>
<image>
...
</image>
<write>filename='testpic.png'</write>
</group>
Also the order in which parameters are written are not the same order as i instruct the document creator to generate it.
So i'm trying to figure out how flexible MSL really is in interpreting the xml stuff and if parameters are also allowed to be served as nodes.
This snippet of Lua code:
Code: Select all
function document_test(width,height,wmargin,hmargin,fgc,bgc,bdc)
local xstart = wmargin
local xend = width - wmargin
local ystart = hmargin
local yend = height - hmargin
-- local image_file = os.tmpname(".png")
local my_document = app.Document.create("group") {
image={
size = tostring(width).."x"..tostring(height),
draw={
primitive="line",
xc=bgc,
fill=fgc,
stroke=bgc,
points=tostring(xstart)..','..tostring(ystart)..','..tostring(xend)..','..tostring(yend),
draw ={
primitive = "path",
stroke="red",
fill="yellow",
points = "M 70,10 l -15,-5 +5,+5 -5,+5 +15,-5 z"
}
},
},
write="filename='testpic.png'"
}
my_document:save_as('test.msl')
os.execute(IM_CONJURE..' test.msl -verbose -debug')
end
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<group doc_version="0">
<write>filename='testpic.png'</write>
<image>
<draw>
<xc>white</xc>
<draw>
<primitive>path</primitive>
<stroke>red</stroke>
<points>M 70,10 l -15,-5 +5,+5 -5,+5 +15,-5 z</points>
<fill>yellow</fill>
</draw>
<primitive>line</primitive>
<stroke>white</stroke>
<points>10,10,70,10</points>
<fill>black</fill>
</draw>
<size>80x20</size>
</image>
</group>
What i'm trying to aim for here is that MSL has a great potential for usage in these kind of generic scripting languages (tool applications that use it, games that use a scripting language and allows third party tools to run) as a nice library add-on.
Are there any plans to make MSL more flexible, scan the code for tags and/or parameters regardless of their order yet ignore what it doesn't know?
The current way the XML document API in my tool works is, well unusable for MSL now, so i have to rewrite this XML document management myself to be able to circumvent the limitations and allow adding parameters inside the node tags.
The other thing i need to know is the minimum required files for conjure / convert to work on any platform. The Windows autonome zip package is a whopping 45MB, i doubt i need everything to make this work but i also don't know what i can exactly leave out.