-
Notifications
You must be signed in to change notification settings - Fork 2
How to migrate an xml scripts base o8g to python
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:
-
Add the extension "py" (for Python files) inside [Content_Types].xml. See an example here: Game Definition (o8g).
-
Create a python files somewhere in the package, e.g. \scripts\actions.py. Again see Game Definition (o8g) for an example file structure.
-
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" />
- 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.