Adam's Lair Forum

game development and casual madness
It is currently 2017/04/25, 10:45

All times are UTC + 1 hour [ DST ]

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: 2017/04/15, 19:55 
Forum Adept
Forum Adept

Joined: 2014/12/13, 00:11
Posts: 397
Location: Brazil
Role: Gamer
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.

Example 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.

import Duality
from Duality.Component import InitContext
class PyModule:
    def __init__(self):

    # 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 Plugin
Editor Plugin
Source code

I only know the basics of C#. I have no advanced knowledge.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group