Separate Scripts

Comments

1 comment

  • Support Admin

    You can separate the Lua script from the XML using fragments. It doesn't work exactly like .js files (the script is still kept in .xml files), however it does help to reduce your code and keep everything a little more organised. 

    To use fragments, you need to create an additional XML file and add it to your project. In Visual Studio, go to File > New > File > XML file.

    Replace the default text in that new XML file with:

    <?xml version="1.0" encoding="utf-8"?>
    <fragment xmlns="http://resources.qdexapps.com/schema/v1/QDocument.xsd">
        <script>
    input lua here...
    </script> </fragment>

    Save the file (e.g. myScriptFragment.xml). If you would like to see this new file in the Solution Explorer window, you can right-click on your open project and select Add > Existing Item. Search for your saved fragment file and select Add.

    In your main document.XML file, you can add the Lua script fragment to your project by including the file. 

    <include src="myScriptFragment.xml"/>

    You can include the script fragment anywhere (inside or outside of sections). I recommend including the fragment in the same location you would have had the script, just to keep things organised for yourself. You can also break down your scripts across multiple fragments, or you can keep all the scripts in a single fragment.  

    0
    Comment actions Permalink

Please sign in to leave a comment.