Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/189769376520605696
Reformulated the question
Source Link
doppelgreener
  • 7.3k
  • 7
  • 43
  • 69

My XNA game is component-oriented, and has various components for position, physics representation, rendering, etc, all of which extend a base Component class. The player and enemies also have controllers which are currently defined in C#. I'd like to turn them into Python scripts, but via IronPython (a .NET implementation of Python). My problem is that I'm not sure how to interact with those scripts.

The examples in Embedding IronPython in a C# Application suggest I'd have to create a wrapper class (e.g.something like a ScriptScript component) which compiles a Python script, and callcalls the controller's Update methods of the component in the script

Is this the most effective way of working with a Python object?method via Python - essentially, it'd be a wrapper class for C# to interface with Python.

I feel that I'm missing something in my research - there. There must be a way to load up a script, instantiate a Python object (either in the Python script or in C#) and then workthen have a directlydirect with it from withinreference to that Python object in my C# code. Or is the wrapper required?

Is there a way to work with an IronPython object directly, or is a wrapper required?

My XNA game is component-oriented, and has various components for position, physics representation, rendering, etc, all of which extend a base Component class. The player and enemies also have controllers which are currently defined in C#. I'd like to turn them into Python scripts, but I'm not sure how to interact with those scripts.

The examples in Embedding IronPython in a C# Application suggest I'd have to create a wrapper class (e.g. a Script component) which compiles a Python script, and call the Update methods of the component in the script

Is this the most effective way of working with a Python object?

I feel that I'm missing something in my research - there must be a way to load up a script, instantiate a Python object and then work directly with it from within C#. Or is the wrapper required?

My XNA game is component-oriented, and has various components for position, physics representation, rendering, etc, all of which extend a base Component class. The player and enemies also have controllers which are currently defined in C#. I'd like to turn them into Python scripts via IronPython (a .NET implementation of Python). My problem is that I'm not sure how to interact with those scripts.

The examples in Embedding IronPython in a C# Application suggest I'd have to create something like a Script component which compiles a Python script and calls the controller's Update method via Python - essentially, it'd be a wrapper class for C# to interface with Python.

I feel that I'm missing something in my research. There must be a way to load up a script, instantiate a Python object (either in the Python script or in C#) and then then have a direct reference to that Python object in my C# code.

Is there a way to work with an IronPython object directly, or is a wrapper required?

Source Link
doppelgreener
  • 7.3k
  • 7
  • 43
  • 69

How do I communicate with an IronPython component in a C#/XNA game?

My XNA game is component-oriented, and has various components for position, physics representation, rendering, etc, all of which extend a base Component class. The player and enemies also have controllers which are currently defined in C#. I'd like to turn them into Python scripts, but I'm not sure how to interact with those scripts.

The examples in Embedding IronPython in a C# Application suggest I'd have to create a wrapper class (e.g. a Script component) which compiles a Python script, and call the Update methods of the component in the script

Is this the most effective way of working with a Python object?

I feel that I'm missing something in my research - there must be a way to load up a script, instantiate a Python object and then work directly with it from within C#. Or is the wrapper required?