Jump to content

Modding in other programming languages


Recommended Posts

Hi,

would it be possible to implament a lua or python modding API?

I think this would be good as C# is quite alien and complex to a lot of people, and anyone can pick up lua or python in a couple weeks, while C# is quite hard to learn.

also, 2 python implamentations for mono / microsoft .NET already exist: http://pythonnet.sourceforge.net/  and http://ironpython.net/

 

Edited by kerbingamer376
fixed stuf
Link to comment
Share on other sites

http://forum.unity3d.com/threads/about-python-and-unity.87790/

The TL;DR seems to be theoretically yes.

In addition to C#, Unity by default also supports JavaScript, so presumably that might be an alternative that's supported out of the box.

Having said that, I should point out that whilst I've dabbled a little in Unity, I have zero experience modding KSP, so I'm kind of guessing here.

 

(Interestingly enough, looking at the thread linked in the link above -> http://forum.unity3d.com/threads/python-interpreter-in-unity.86461/
check out post #2.  That's our HarvesteR i presume?)

Edited by pxi
Link to comment
Share on other sites

Theoretically, you should be able to program in any of Microsoft's CLI supported languages as once they are compiled into a DLL they should be essentially the same thing.  That means you could program it in Visual Basic or Python.   In practice I can't say I've attempted it.

Lua is a scripting language.  You are comparing apples and oranges there.  That's like comparing HTML to C++.

Edited by Alshain
Link to comment
Share on other sites

8 minutes ago, Alshain said:

(...) Lua is a scripting language.  You are comparing apples and oranges there.  That's like comparing HTML to C++.

...but so is Python. Don't get me wrong, I like Python, but what would make it different from Lua in that respect (aside from the fact that there are apparently two .NET implementations of Python now)? Or do you mean "standalone Lua" as opposed to .netted version of Python?

Link to comment
Share on other sites

13 minutes ago, Kerbart said:

...but so is Python. Don't get me wrong, I like Python, but what would make it different from Lua in that respect (aside from the fact that there are apparently two .NET implementations of Python now)? Or do you mean "standalone Lua" as opposed to .netted version of Python?

Is it?  I know nothing of Python, never used it before.  I just figured if it had a .Net implementation that would be sufficient.  If that is the case, then you probably won't be able to do it in Python either.  It's not about being .NET, Unity doesn't use .NET even though it uses .NET languages (essentially, Unity REPLACES .Net, if it used .NET it would be Windows only).  It's about its capability to access the CLI.

Edited by Alshain
Link to comment
Share on other sites

One other possible option, depending on what you're trying to accomplish -  kRPC is a mod that handles moving data in and out of KSP via TCP connection...  and it has libraries in python, ruby and lua.  It doesn't expose EVERYTHING and you can't manipulate lower level things...  but SOME basic modmaking could be done using this framework, so the 'mod' runs outside of KSP in the python app.

The most frustrating thing about modmaking is how little official documentation there is.  Almost all of the documentation available for plugin building is community maintained and I think most of us who toy with it have learned more from studying the mechjeb code than we have from anything else.  Figuring out how to do things in a different language than what most of the available examples are written in would be very difficult if Squad wasn't going to commit to keeping up to date info on the Python API available (Which, seeing as how they've made no effort to do this for the C# API... doesn't seem likely)  With the current way of doing things, I think keeping all the modmaking in the same language where we can help each other is more important.  Learning to code in C# with lots of support and folks to answer questions is easier, in my opinion, than coding in a language you're used to but not having people around who know the API to help you chase down a bug or figure out how to implement a feature when you run into a problem. 

Besides.  Fortran would be the way to go. :P  

Link to comment
Share on other sites

You can learn most of what you need by studying the Object Browser in .Net, though some documentation on the more cryptic named messages would be nice.

9 minutes ago, artwhaley said:


Besides.  Fortran would be the way to go. :P  

I sure hope you mean Fortran II :P  Kerbal by Punchcard doesn't sound like fun to me.

Link to comment
Share on other sites

19 minutes ago, Alshain said:

You can learn most of what you need by studying the Object Browser in .Net, though some documentation on the more cryptic named messages would be nice.

I sure hope you mean Fortran II :P  Kerbal by Punchcard doesn't sound like fun to me.

Can you get KSP for IBM mainframe? how many cards long is it? :)

Link to comment
Share on other sites

55 minutes ago, Alshain said:

Is it?  I know nothing of Python, never used it before.  I just figured if it had a .Net implementation that would be sufficient.  If that is the case, then you probably won't be able to do it in Python either.  (...)

I do most of my programming in Python but I don' have IronPython experience. Some googling revealed that it is unlikely. You can create a .exe and even create (iron)python assemblies but you wouldn't be able to have them interact with C# code (mainly because types in Python are fluid, and in C# are not). It seems that IronPython is really about "running Python code in a .NET environment, and not "writing .NET assemblies in the Python language" as you correctly pointed out.

As per StackOverflow:

Quote

This isn't really possible if your goal is to create an assembly which contains types that look like the types created by C#. The main problem here is that Python types work considerably differently than CLR types. For one thing, they can be mutated at runtime while CLR types are totally static. So the only way to achieve this today is to use the hosting interfaces to create a small C# stub which delegates the work to Python code.

IronPython does have the ability to compile to an assembly -- which is what that blog post refers to -- but we did this primarily so that you could deploy an IronPython application to your customers without having to give them the source code.

 

Link to comment
Share on other sites

46 minutes ago, Kerbart said:

I do most of my programming in Python but I don' have IronPython experience. Some googling revealed that it is unlikely. You can create a .exe and even create (iron)python assemblies but you wouldn't be able to have them interact with C# code (mainly because types in Python are fluid, and in C# are not). It seems that IronPython is really about "running Python code in a .NET environment, and not "writing .NET assemblies in the Python language" as you correctly pointed out.

That doesn't rule out Visual Basic though, as far as I know. I don't exactly like Visual Basic, but could it theoretically be used as a Kerbal Modding language, as seen here: http://forum.kerbalspaceprogram.com/index.php?/topic/74366-protip-for-new-modders-c-isnt-the-only-language-you-can-use/

So apparently, a KSP mod in VB.NET, if a bit unorthodox, is theoretically possible, but as far as I know no (major) KSP mod is programmed in Visual Basic, and documentation for doing so in Visual Basic is likely very sparse, if it exists at all.

In the end, unless you really hate C#, you should make your mod in C#.

Link to comment
Share on other sites

31 minutes ago, Norpo said:

That doesn't rule out Visual Basic though, as far as I know. I don't exactly like Visual Basic, but could it theoretically be used as a Kerbal Modding language, as seen here: http://forum.kerbalspaceprogram.com/index.php?/topic/74366-protip-for-new-modders-c-isnt-the-only-language-you-can-use/

So apparently, a KSP mod in VB.NET, if a bit unorthodox, is theoretically possible, but as far as I know no (major) KSP mod is programmed in Visual Basic, and documentation for doing so in Visual Basic is likely very sparse, if it exists at all.

In the end, unless you really hate C#, you should make your mod in C#.

Yes. VB6 wasn't the most charming language but it had some things going for it (mainly due to its interchangeability with VBA). VB.NET is, as far as I'm concerned, "C# without the curly braces" (I'm sure someone will take offense to this but I haven't had a warning from the mods in a while, so I can take it). In the end, learning VB.NET is pretty much the same as learning C# which is why most people don't bother with it, I think; Microsoft did a good job in killing off one of their most popular languages.

And since C# is a managed language it doesn't have the challenges that learning C or C++ brings along.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...