NanoBob

Slipe - C# for MTA

Recommended Posts

Posted (edited)

logo_large.png

 

Slipe is an open source framework that enables anyone to write scripts for MTA:San Andreas in C# instead of Lua, wrapping all MTA elements and classes and including some .NET Core namespaces. It is based on CSharp.Lua by Yang Huan.

Slipe features:

  • Runs on Windows and Linux
  • Built in continuous deployment support with (GitHub) webhooks
  • Object oriented wrappers for all MTA elements
  • Async/await for MTA functions that use callbacks
  • C# style Http requests, sockets and XML methods.
  • Use Visual Studio and its Intellisense
  • Type safety

You can find more information about the project on https://mta-slipe.com.

The project is still in Alpha, and since it is open source anyone is welcome to contribute

yfBGZRa.png

Edited by NanoBob
  • Like 13
  • Thanks 1

Share this post


Link to post

Wow! Really interesting and promising project. :thumbup:

I'd be interested in the performance overhead of the wrapper, especially in regards to conversion from and to types C# doesn't have exact equivalents for (e.g. tables). Have you already done some benchmarking?

EDIT: Also, I'm just curious: Have you considered using TypeScript as the wrapper language when you started the project?

  • Like 2

Share this post


Link to post
Posted (edited)

We haven't necesarily done benchmark tests, however inspecting the generated Lua code and the OO library used it's not much different than a "regular" Lua OOP library would be.

Regarding the data types which do not have an exact conversion, that's exactly why we've created our wrappers around MTA classes. This means that in end user's (or end programmer / scripter) code you will not need to directly use Lua data types returned by MTA functions. But for the purpose of tables these are approached as arrays or dictionaries depending on their usage.

 

EDIT:
As a reply to your edit: no, but C# > Typescript IMO
Our current MTA project actually consists of several parts of which all but the actual MTA part was written in C#, so this was a perfect way to use the same language on all ends.

Edited by NanoBob

Share this post


Link to post

Man that's a great idea, so are we able to make the mods of gta sa that are written in .cs files works on mta sa servers? 

Share this post


Link to post

I believe what you're referring to are CLEO mods, whilst CLEO does use the .cs file extension it's not C#, so no that wouldn't work.

Share this post


Link to post

The Slipe CLI tool has been updated today. New features include:

  • A `slipe build` command to produce a deployment ready resource, including a `-luac` option to automatically compile the lua files using the MTA compiler.
  • Self updating functionality, no longer will you need to manually update the CLI or core after this update.
  • Exporting and import of modules. Your project can exist of seperate smaller modules, which can be exported and shared with others in the Slipe community.

 

For more information on the CLI visit the documentation on mta-slipe.com

Share this post


Link to post

Here's a little teaser of a work in progress first party module for Slipe, called SlipeWPF.

For those of you unaware of WPF, it's a GUI framework which allows you to create windows desktop applications. We're also bringing this to MTA.

unknown.png

This window, created in Visual studio, will turn into:

unknown.png

And all it requires to render it in MTA is this little bit of code:

MainWindow window = new MainWindow();
Window guiWindow = CeguiWpfRenderer.Render(window);

 

  • Like 3

Share this post


Link to post

A new version of both the CLI and the core have been released!

Root Events
Events which you would want to handle on the rootElement (For example onPlayerJoin) have now been implemented as static events on that class. For example `Player.OnJoin`

Defining default classes
If you wish to extend a Slipe class and make it the default class for any element of that type you can do so now using the `DefaultElementClass` attribute, you can read more about that on https://mta-slipe.com/docs/inheritance.html

New updater
The previous updater for the CLI was a bit crap, so the windows installer has been redone as a standalone .exe, you can download this at https://mta-slipe.com/downloads/SlipeInstaller.exe. After that you should be able to use `slipe update` like should have been (but wasn't) possible with the previous updater.

Updating an existing project?
After updating your CLI you can update your existing Slipe projects using `slipe update-core` in the root directory of the project.

Share this post


Link to post

Wait, so this is a parser? I thought this release enables write, run and use C# as a backend for MTA:SA.

Share this post


Link to post
44 minutes ago, Kaperstone said:

Wait, so this is a parser? I thought this release enables write, run and use C# as a backend for MTA:SA.

It's basically both. It does allow you to write C# for MTA:SA, and it does this by translating that C# code to Lua.

Share this post


Link to post
Posted (edited)
2 hours ago, NanoBob said:

It's basically both. It does allow you to write C# for MTA:SA, and it does this by translating that C# code to Lua.

but I don't get the benefit in performance.

 

 

Is it even possible to bind to MTA's events from another langauge?

Edited by Kaperstone

Share this post


Link to post
16 hours ago, Kaperstone said:

but I don't get the benefit in performance.

The benefit of doing this isn't necesarily performance, but it's the benefits that a strongly typed language such as C# brings with it. But also the tooling that you're able to use for C#, Visual Studio's intellisense especially is great to speed up your development time.

 

16 hours ago, Kaperstone said:

Is it even possible to bind to MTA's events from another langauge?

It is, because in the end this project just generates Lua code. And MTA events are implemented in our wrapper as C# events. An example of this can be found in the code snippet on the front page of https://mta-slipe.com 

II33Flg.png

Share this post


Link to post

Very interesting. I'm not very much into Lua but I am very much into C# so I will be looking into this. Also looking forward to SlipeWPF. Is it possible to use NuGet packages as well?

Share this post


Link to post
1 hour ago, Corne said:

Very interesting. I'm not very much into Lua but I am very much into C# so I will be looking into this. Also looking forward to SlipeWPF. Is it possible to use NuGet packages as well?

It is not, sadly. This is due to the fact that all C# has has to be turned into Lua code in order to be run. With a NuGet package you only get the compiled DLL.
If the package is open source however (And if it only uses C# classes / libraries that are implemented in slipe) then you should be able to compile it from the source using Slipe. But keep in mind that only very basic C# libraries are currently implemented in Slipe (and many only partially).

Share this post


Link to post

Oh. This nice work! How much does the performance of the Lua code fall?

Share this post


Link to post
On 11/05/2019 at 21:10, XaskeL said:

Oh. This nice work! How much does the performance of the Lua code fall?

We have not yet run benchmarks comparing "regular" Lua and Slipe, but we're planning on doing so in the near future. But by inspecting the generated Lua code and the class library the overhead should not be much more (if any) than a "plain" Lua OO implementation.

Share this post


Link to post

A new version of both the CLI and the core have been released!

Events
Events have undergone a major refactor, all events now have a `source` and an `eventArgs` parameter. This will allow us to add parameters to events without breaking backwards compatibility. This also aligns more with C# convention.

Vehicles
The vehicle "lookup" classes have been changed to reflect vehicle types.

Exports
It is now possible to export static methods from your Slipe resource. For more information on how to do so visit https://mta-slipe.com/docs/exporting.html

Updating
In order to update the CLI use `slipe update`
In order to update an existing project use `slipe update-core`

Also we would like to thank those who contribute to Slipe, you guys are awesome!
https://github.com/mta-slipe/Slipe-Core/graphs/contributors

Share this post


Link to post

A new version of both the CLI and the core have been released!

Changes

  • several bugfixes
  • C# reflection is now supported due to metadata being included in compilation

Updating

In order to update your CLI run `slipe update`
In order to update your projects run `slipe update-core` in the project directory

Infrastructure

From this point on the Slipe website is hosted in a datacenter (instead of a PC at my home)
We have also set up a continuous integration / deployment environment so the downloads on the website will always be up to date.

Share this post


Link to post

Nice work. We really need something like this.

Share this post


Link to post

A new version of the CLI has been released!

 

Github webhooks

The slipe CLI now has built in support for automatically deploying a Slipe resource using github webhook using the `slipe hook` command. More information on how to set it up can be found on https://mta-slipe.com/docs/webhook.html


 

Updating

In order to update your CLI run `slipe update`

Share this post


Link to post

This is the single best thing that ever happened in the MTA ecosystem. Being able to hire c# devs to do MTA programming. Great job!

Share this post


Link to post
Posted (edited)

A new version of the CLI and core have been released!

Updating from dev
Since Slipe is still in development and we can't always make releases to hotfix an issue we've added the ability to update your CLI and project to the current development branch of the repo.

What this means is you will be running the latest version, however these versions are more prone to bugs / unfinished features.

In order to update the CLI from the development branch use:
`slipe update -dev` 
In order to update a project from the development branch use:
`slipe update-core -dev`

Element data
sigh, we've implemented element data. We still recommend people don't use it if you can. The only reason we implemented it is to support compatibility with non-slipe resources or mapping files.

Bugs
We've fixed several bugs, including some important ones related to events.

Updating
In order to update your CLI run `slipe update`
In order to update an existing project use `slipe update-core`


Also, update your .net core 3.0 to the most recent preview (preview 7)

Edited by NanoBob
  • Like 1

Share this post


Link to post

A new version of the CLI and core have been released!

RPCs
RPCs being split up into two seperate classes was a bit unintuitive. So we've combined them into a single class. More information on how RPCs work now on https://mta-slipe.com/docs/rpc.html

Slipe WPF
We've released our first "first party module". Slipe WPF!
Slipe WPF allows you to create Windows Presentation Foundation (WPF) user interfaces in Visual studio, and then run these in MTA. 
Warning Slipe WPF is even more alpha than Slipe itself. So no guarantees that it will be bug free.

Information on setting up WPF can be found on: https://github.com/mta-slipe/Slipe-wpf
A sample resource using WPF can be found on: https://github.com/mta-slipe/Slipe-login


Updating
In order to update your CLI run `slipe update`
In order to update an existing project use `slipe update-core`

ZL2Y8U0.png

 

TNfnaUn.png

Share this post


Link to post

Keep it up man.

Share this post


Link to post

A new version of the CLI and core have been released!

RPC bug
An issue has been fixed with RPCs, RPCs now work as expected when registering multiple handlers to the same RPC key

Update to dotnet core 3!
Slipe now runs on non preview versions dotnet core 3, this means you no longer need to use visual studio 2019 preview (use the regular 2019 version, make sure to update it to the latest). And you will no longer need to specify the use of experimental frameworks.


Updating
In order to update your CLI run `slipe update`
In order to update an existing project use `slipe update-core`

Edited by NanoBob

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.