Skip to content

How to migrate an xml scripts base o8g to python

drilus edited this page May 7, 2012 · 8 revisions

For a limited time (starting with 0.9, probably ending with 0.10 or 0.11), one can mix XML-scripts and Python as much as desired. But it is important to get rid of the XML scripts as support for those is going to be removed soon.

Taking an existing .o8g with actions in XML, here are the steps required to make it compatible with future releases:

  1. Add the extension "py" (for Python files) inside [Content_Types].xml. See an example here: Game Definition (o8g).

  2. Create a python files somewhere in the package, e.g. \scripts\actions.py. Again see Game Definition (o8g) for an example file structure.

  3. Reference the python file(s) from your game.xml.rels relationship files. The correct type for the relationship is http://schemas.octgn.org/script . Example of a correct relationship:

        <Relationship Target="/scripts/actions.py" Id="r10" Type="http://schemas.octgn.org/script" />
  1. Inside your game.xml, remove any section you may have. Add a section, like this one:
        <scripts>
            <script src="r10" />
        </scripts>

This comes before any other tag. The src should contain the Id of the relationship created in the previous point.

Finally, remove all xml scripts from inside and and replace them with either an execute or batchExecute attributes, referencing the Python function to run instead.

Also be sure to put octgnVersion="0.9" at least on your game tag. Future OCTGN release will be incompatible with games requiring any OCTGN version less than 0.9, because of the removal of XML scripts.

For more details on the correct game.xml structure, please look at XML game description. The correct Python functions signature is described in Action Definition.

Clone this wiki locally