### C# - need someone to poke around

Friendly conversations, and everything that doesn't fit into the other forums.
• 1
• 2

#### C# - need someone to poke around

LukasPJ
Posts: 348
Joined: Tue Feb 03, 2015 7:25 pm

Hey guys,

So, I've implemented T3D into C# in order to provide a C# scripting interface for the engine. It's still very much a work in progress, so it's not nice or anything. It's more or less a proof of concept.

So I'm looking for someone interested in downloading the attached binaries, opening it up and taking a stab at it just doing different things you are curious about and reporting any marshalling errors for me.

Be advised, that this is not polished in any way and you should know your way around TorqueScript, C# and Torque itself in order to figure out how to use it.
The attached code file delivers the following:
• The Empty project with a compiled DLL
• A folder "c#" with the following:
• A C# project "Game" with a file program.cs which initializes the engine and TestScript.cs which is a translation of the main.cs file
• A C# project "Torque3D" with all the interop-code and proxy classes in order to interact with Torque3D.

Feel free to ask any specific questions about how it works and report all bugs you find. Thanks a ton!

Edit:
In case anyone is curious, here is a comparison between main.cs in C# and TorqueScript and there's also a bit more information to be found in the now-inactive Torque6-C# wiki: https://github.com/lukaspj/Torque6-Embedded-CSharp/wiki

#### Re: C# - need someone to poke around

RasterRon
Posts: 53
Joined: Sun Oct 25, 2015 7:36 am

This looks interesting Lukas, so basically you can still use both TorqueScript and C#? nice.

#### Re: C# - need someone to poke around

deathbravo
Posts: 50
Joined: Mon Feb 01, 2016 7:06 am
when i first run it in cmd console, it gives :

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at Torque3D.GuiCanvas.showWindow() in D:\GameDev\Torque3D-Hobby\Torque#-Alpha
\c#\Torque3D\Torque3D\Engine\GuiCanvas.cs:line 940
at Game.TestScript.entry() in D:\GameDev\Torque3D-Hobby\Torque#-Alpha\c#\Torq
ue3D\Game\TestScript.cs:line 142
at Torque3D.Torque3D.Initialize(String[] args, Libraries libraryNames) in D:\
GameDev\Torque3D-Hobby\Torque#-Alpha\c#\Torque3D\Torque3D\Torque3D.cs:line 121
at Game.Program.Main(String[] args) in D:\GameDev\Torque3D-Hobby\Torque#-Alph
a\c#\Torque3D\Game\Program.cs:line 17

then I tried it in visual studio, it works. Then it can work in cmd console without the exception thrown.

#### Re: C# - need someone to poke around

LukasPJ
Posts: 348
Joined: Tue Feb 03, 2015 7:25 pm

RasterRon wrote:This looks interesting Lukas, so basically you can still use both TorqueScript and C#? nice.

Yeah, TorqueScript works just like it has always done. C# is just an optional layer on top of that.. It doesn't even have to be merged into the official repo!

@
deathbravo
Huh, that's really odd. Thanks for reporting the issue! I'll have a look at it, seems like it might just be some outdated binaries or something though.

#### Re: C# - need someone to poke around

RasterRon
Posts: 53
Joined: Sun Oct 25, 2015 7:36 am

Yeah, TorqueScript works just like it has always done. C# is just an optional layer on top of that.. It doesn't even have to be merged into the official repo!

Got it and that's awesome! I'm also getting the same error as
deathbravo
.

#### Re: C# - need someone to poke around

LukasPJ
Posts: 348
Joined: Tue Feb 03, 2015 7:25 pm

RasterRon wrote:
Yeah, TorqueScript works just like it has always done. C# is just an optional layer on top of that.. It doesn't even have to be merged into the official repo!

Got it and that's awesome! I'm also getting the same error as
deathbravo
.

Just had a chance to look at it, and apparently the precompiled .exe file is outdated. So recompiling it through VS should fix it. I'm updating an updated .zip file soon

#### Re: C# - need someone to poke around

Monkeychops
Posts: 17
Joined: Wed Feb 18, 2015 11:53 am
Seems to run for me, although not sure how to do much except start the blank scene.
This is really cool - I have to say I've kinda given up on Torque because TS is too quirky and not a lot of open source libraries and such out there for it.. but C# would be a whole new story.

#### Re: C# - need someone to poke around

RasterRon
Posts: 53
Joined: Sun Oct 25, 2015 7:36 am

LukasPJ wrote:Just had a chance to look at it, and apparently the precompiled .exe file is outdated. So recompiling it through VS should fix it. I'm updating an updated .zip file soon

Ah ok thanks. Apparently I still have to do a VS2015 reinstall and my latest working here is 2010 but anyway, looking forward to it.

#### Re: C# - need someone to poke around

LukasPJ
Posts: 348
Joined: Tue Feb 03, 2015 7:25 pm

Monkeychops wrote:Seems to run for me, although not sure how to do much except start the blank scene.
This is really cool - I have to say I've kinda given up on Torque because TS is too quirky and not a lot of open source libraries and such out there for it.. but C# would be a whole new story.

Honestly, I don't mind TorqueScript, but yeah the reason I'm doing this C# thing, is because of a Hackathon I want to hold at my University, and I don't feel like asking people to learn TS in a day

On another note..

## New release!

This release features:

### Properties

All SimObjects static fields can now be accessed like regular C# properties:
StaticShape coin = Sim.FindObject<StaticShape>(obj);ParticleEmitterNode emitterNode = new ParticleEmitterNode{   DataBlock = Sim.FindObjectByName<ParticleEmitterNodeData>("CoinNode"),   Emitter = Sim.FindObjectByName<ParticleEmitterData>("CoinEmitter"),   Position = coin.Position};emitterNode.registerObject();emitterNode.schedule(200, "delete");

They are all going through the console, so they are converted to and from string which of course is sub-optimal. But it's something!

Furthermore, I added some more sample C#. scripts.. Namely first and second part of this tutorial:
http://wiki.torque3d.org/scripter:coincollection
I still haven't fixed creation of datablocks, so they are eval'ed atm but small steps all the time!

#### Re: C# - need someone to poke around

Online JeffR
Steering Committee
Posts: 741
Joined: Tue Feb 03, 2015 9:49 pm

You sexy beast!

Very awesome. I need to give this a proper run-down.

So outside of obvious, improvements like cutting back on how much string interpretation we use and whatnot, what do you think is still missing at least an initial implementation?

It's sounding like it's pretty close to at least the 'everything runs' level.
• 1
• 2

#### Who is online

Users browsing this forum: No registered users and 1 guest