[quote="R0J0hound":1ly30354]Tulamide, they should work identically, I suspect the blank __init__.pyd caused it not to work. I didn't "import sys" because it was already imported when Construct initialized python.[/quote:1ly30354]
Thank you, R0J0hound
. The information about sys is stored
For the curious among us: The blank file I mentioned should be named __init__.py
not .pyd (two leading and two trailing underscores), and is a kind of identifier for a python package. The __init__.py files are required to make Python treat the directories as containing packages.
This is a python package folder structure inside your games folder:
The package is identified by its name "plants".
Now you only need to add the current working directory (= the path to your games folder) to sys.path:
version 1 is of help if you happen to import a package from within a module.
Either way, the package is now available for import. You access them with their folder and module names in a dot structure, and there are several ways to import what you need:
This imports the module oak, and it must be referenced in code with the full name structure:
[code:1ly30354]plants.trees.oak.grow(speed, branch)[/code:1ly30354](assuming, grow is a function of the module oak)
A reference shortcut is:
[code:1ly30354]from plants.trees import oak[/code:1ly30354]
Now oak can be referenced directly:
These techniques work for all files that are imported directly using import, either pure python or extensions (like the dll for python, identified by the extension .pyd)