I decided to write a simple plugin, just for fun, based off skoggy's Lua Scripting plugin for Duality. I thought "why not add Python scripting support as well?", and this is the result.
It's available on NuGet, and it's split into 2 plugins:
- The Editor plugin, which adds support for adding/removing/editing .py files
- The Core plugin, which as the name suggests, adds all the core functionality of the plugin (execution engine, etc)
It's pretty straight forward, I've also included some notes in the default script file that is generated when you create a new script.
# You can access the parent GameObject by calling `game_object`.
# To use Duality classes, you must first import them:
# from Duality import Vector2
# By using `import Duality`, you must use qualified names:
# import Duality
# Duality.Log.Game.Write('Hello, world!')
# All code must be inside a class called `PyModule`.
# Code outside the class scope will be executed as well,
# except that you won't be able to access functions nor variables.
from Duality.Component import InitContext
# Called when a Component is initializing.
# `context`: what kind of initialization is being performed on the Component.
def start(self, context):
if context == InitContext.Activate:
# Called once per frame in order to update the Component.
# `delta`: time the last frame took, in milliseconds, with time scale applied.
def update(self, delta):
print('Time last frame took: %d ms' % delta)
Let me know if you need any help or if you have any feedback.Core PluginEditor PluginSource code