Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

MDK: Malware's DevKit for Space Engineers

Discussion in 'Programming (In-game)' started by Malware, Aug 12, 2017.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Malware Master Engineer


    (Malware's Development Kit for SE)

    A toolkit to help with ingame script (programmable block) development for Keen Software House's space sandbox Space Engineers. It helps you create a ready-to-code project for writing ingame scripts, and provides an analyzer which warns you if you're trying to use something that is not allowed in Space Engineers.

    General features
    • Helps you create a fully connected script project in Visual Studio 2017, with all references in place
    • Requires that you have the game installed, but does not require you to have it running
    • Class templates for normal utility classes and extension classes
    • Tells you if you're using code that's not allowed in Space Engineers (whitelist checker)
    • Deploys multiple classes into a single PB script, which then is placed in the local Workshop space for easy access in-game - no copy/paste needed
    • Supports optional code minifying: Fit more code within the limits of the programmable block
    • Allows real reusable code libraries through the use of Visual Studio's Shared Project
    • Out-of-game script blueprint manager allows you to rename and delete script blueprints without starting the game
    Quick links
    Last edited: Aug 20, 2017
    • Like Like x 14
  2. theCalcaholic Trainee Engineer

    Sounds very cool! Definitely going to use it.
  3. Regn Trainee Engineer

    I've been thinking about developing something for a while now where a .cs file could be opened in a pan to the left, and output an alternative version to a pan on the right. It would remove using, namespace, program, and comments, and variables would be abbreviated to allow for more characters, and it would say how many characters were used. So basically the file used in Visual Studio would go in the pan to the left, and the output would be directly stored into the Space Engineers script folder to be picked up in-game.

    But this sounds like it comes with a lot more practical features, many of which I could learn new things from. I'm slightly discouraged at the moment having dealt with an unresolved thruster and gyroscope issue for a week, but I'm definitely interested and will look into this ASAP.
  4. Ronin1973 Master Engineer

    MMaster and his Automatic LCDs is a great example of squeezing as much code into a space as possible. Just scrolling through it makes me feel like I'm dyslexic. He'd be at evaluating this.
  5. Malware Master Engineer

    He already has evaluated it. Apparently my minifier is better at minifying than the one he uses, from what he tells me. But since mine is still bare-bones (didn't consider it priority-one for first release) it doesn't have enough control for his use just yet. He wants to keep certain parts unminified for configuration. I don't support that yet, but I have anticipated that request so I have plans for it. Eventually.
    • Informative Informative x 1
  6. Ronin1973 Master Engineer

    Are there any benefits other than space-saving? Not that space-saving in itself is something to sneeze at, I'm just curious.
  7. Malware Master Engineer

    No the minifier is specifically to fit big scripts into the programmable block. I would not recommend minifying scripts that already fit, there's nothing to gain and obviously you lose readability.
    • Agree Agree x 1
  8. Malware Master Engineer

    Finally. The first public release is ready.

    From here on out, it's your choice whether you want to keep on helping me by downloading prereleases or stick to the public ones only. If you do choose to help me, please go to Tools | Options, find MDK/SE in the list and make sure "Include prerelease versions" is checked.

    Thank you to all the people who have helped out so far. Here's hoping this tool becomes popular enough to warrant further enhancement!
    • Informative Informative x 1
  9. Neunzehn Trainee Engineer

    I came back from a two-year afk from SE in game programming, and I have to say this new extension is amazing.
    I've already tried it out and it worked like one of those tools that you dreamed you could build when you were copying, pasting, sharing and managing all the script fragment.
    Thank you for building one of these.
    • Agree Agree x 1
  10. Caithford Trainee Engineer

    I've not really even used it yet, and I'm very excited to start working with it tonight.

    I have a question, and I hope it's not too dumb.

    It appears that the concept is a Project for each script you intend to deploy to a PB. I am loving the Utility class, for sure. My question is, what if I want to use the same Utility class for multiple projects? Is there a way to reduce the C/P between projects within the Solution? Or is that a "maybe sometime later on" kind of feature? You mentioned shared libraries, and I thought maybe that was where to go, but the tutorial is not yet built on the wiki page.

    I am happy to put work in, if it would be helpful, but unfortunately, I'm not adept enough at Visual Studio to really know more than key jamming.
  11. SDragon42 Apprentice Engineer

    I have created some "Shared Project" projects. When you add them as references to your script project, their code will be included in the script when you deploy it.
    • Like Like x 1
  12. Malware Master Engineer

    @Caithford Your question is not dumb at all. I am sorry I haven't had time to write that tutorial yet. I put the priority on the non-MDK stuff in the wiki first. In the mean time, let me suggest you go to Keen's Discord and the programming-in-game channel. There are people there who can help you. Besides, there's generally a lot of helpful people there.
  13. Caithford Trainee Engineer

    Thank you for the suggestion. I will have to bother the Discord folks. No need to apologize on the wiki content, I've read through all of it, and all the content is high quality.

    So far, I really like the toolkit. It does everything that I was wanting a VS extension to do. Separate class files, a minifier, even if the minifier still has a few bugs and is very basic, it's still there. Hell I would have even taken a "copy to clipboard" but the fact you can dump the stuff to the local workshop repository is a step beyond even what I dreamed was possible.

    Thanks for all your hard work. This thing seriously kicks ass.

    Previously was using the VS Solution that BaconFist deployed. It was convenient and basic and at least got intellisense going, but yeah, this is the next level. Plus I can have multiple solutions with multiple projects, rather than a bunch of script files jammed into a single project in a single solution. I'm stoked.

    Also, I think the readme file is super badassed too.

    Some additional feedback. I really like the thumbnail that has the "deployed with MDK" tag. I think it would be okay to add a similar tag line to the template readme.cs file. It would allow people to delete it if they wanted, or leave it in. I would personally leave it in. Which I guess leads me to a question. Is it possible to modify that template without breaking the MDK? I understand that when the MDK updated, if that file were to update I would lose my template, but it would be a simple thing to go re-add my template stuff back in.

    I'll go bug the Discord folks.

    Thanks again for all your hard work. It's a fantastic tool, and I plan on beating the crap out of it as much as I can.
  14. Wicorel Senior Engineer

    Here's the method I used (after help from Malware and Elfi)

    1. File->new-Project->Windows Classic Desktop->Shared Project. Change name to what you want.
    2. Right click on right side name and "add new item'. Select C# Class. Change File name to name you want.
    3. Change default code to have the ingame name space and usings.
    4. Insert your code..
    (repeat 2-4 for as many source files as you want to add)
    (repeat 1-4 for as many shared projects as you want to add)

    5. From MASTER MDK project, Right click solution and 'add existing item'. Select the project you just made
    6. Right click on References and select "Add Reference"
    7. Select 'shared projects' from the dialog. Your project should already be listed. Check the box for what to include. (see picture below)
    8. PROFIT!

    Note that you often need to 'save all' from VS; it doesn't update solution files when you save source.

    Note that including a project (by reference) adds ALL of the source from that project. Since I have lots of shared code, I made many different shared projects so I can pick and choose which 'modules' I need for the particular script I'm working on. I am often working really close to the 100k boundary.

    This is what my one of my "Master" projects looks like. Note that not all of the shared projects are included in this project. Without Minifier, the code is close to 100k.


    From this master MDK solution, you can open any of the shared project source files and make modifications and save them.

    The 'old way' version of this code is here: http://steamcommunity.com/sharedfiles/filedetails/?id=571364878
    • Like Like x 1
  15. Malware Master Engineer

    I honestly don't know. I think the general answer is yes but it's not a simple thing. The template itself is stored in a zip-format file. You'll have to find the installation path of the template, I forget if that's with the extension itself or if it's installed in a VS directory - the VSIX (package installation system) deals with that stuff. I suspect the former. I somehow feel it wouldn't be worth the effort.

    Thank you for your suggestion with the promotion in the readme file, but I think the thumbnail is enough for now. I don't want to push it ;)
  16. Jon Turpin Apprentice Engineer

    Love this, ty Mal!

    Two questions:
    1) Every time I try to debug the code, it shows errors for any GridTerminalSystem.GetBlock line, is there a way to ignore them? I get a "not set to an instance of an object"

    2) I have VS synced between my desktop and laptop so I can work on scripts while testing in-game. I have both upgraded to the lasted release, but I get a neverending loop stating that I need to upgrade the project for it to work properly. Is this just because it isn't locally indexed on one of the systems?
  17. Malware Master Engineer

    1. That has nothing to do with MDK, scripts can't be run outside of the game environment. You'd need to create mockups for all the blocks you need for your script. This is just plain old C#, the blocks simply don't exist for you outside the game. I'm working on such a mockup system but firstly it's a major job, secondly it's not the highest priority and thirdly it would require the involvement of the community in order to create all the mockups. In other words: No promises.

    2. I haven't the slightest idea. Sorry :p
  18. Jon Turpin Apprentice Engineer

    Ahh, okay - I was thinking that the mockup was already in there :p no worries!

    Also -- "Lastest" ..... /facepalm == "latest"! I need more coffee
  19. TehRoach Apprentice Engineer

    Many thanks for this, Mal the software guy :)

    Was getting very annoyed with the PB's UI.

    Any chance that this will one day be a feature of the PB's UI?
  20. Wicorel Senior Engineer

    I'm not Malware, but I can answer.


    It uses Visual Studio..
  21. TehRoach Apprentice Engineer

    Yes I know it uses Visual Studio,
    But autocomplete is not an exclusive feature to VS
  22. Malware Master Engineer

    There is next to zero chance of any improvement of the ingame editor. Especially something like autocomplete or any other IDE feature that's nontrivial to do.
  23. Michael Viktor Starberg Trainee Engineer

    Dear @Malware (@rexxar )

    I have been following Space Engineers from a far since its inception.
    One day I stumbled on a video that mentioned programmable blocks and that the 'scripting' language was C#.

    I just paused the video, went to Steam and bought the game.

    - Here's my money!

    Finally I get to be a see sharper in a game.
    Except it was not really C#. What we got makes GW Basic look great. The flatness of it all.
    I wrote code that I would never commit and never let pass a code review. I was using the oldschool method.

    And as I was an early adopter, I was put off of all the stuff I wanted to code on the side; as whatever I coded looked like GW Spaghetti and always gave me this bad breath. Like I wanted to puke in my mouth.

    Until MDK-SE
    Well played.

    Your nifty way of doing a partial class of Program is not it.
    Letting us use nested classes is not it.
    Shared Projects is not it (It will never work as you want).

    It is how you let us plug it so well.
    I feel sorry for newbies when they stumble on some code that has been Malwared minimized. Is that is how its supposed to look like when baked? :)
  24. UbioZur Trainee Engineer

    First of all Thx Malware!
    This is an awesome tool!
    I set it up yesterday to try and build some scripts! Quick, easy, it was a blast!

    However, today, when I continued on my script, there is no option to deploy MDK script, on any of the scripts I did yesterday or even on the solution! I see MDK in the tool menu, so the plugin must be loaded.

    Any idea on what is going on? I tried in administrator and nothing more.

    Edit: I created a new Project in the solution, and the Deploy is working again. Will see how it goes, but at least I found a way.
    Last edited: Mar 18, 2018
  25. mrbojinkles Trainee Engineer

    Will this MDK work with VScode?
  26. Malware Master Engineer

    No, this is a Visual Studio 2017 extension. VSCode has nothing in common with Visual Studio but the name, I'm afraid.
  27. Cobra Apprentice Engineer

    As a heavy linux user and vscode user I have to try this in vscode :D
  28. Neotician Apprentice Engineer

    Is there a version planned for Visual Studio 2019? :)
  29. Malware Master Engineer

    Yes, of course. Can't promise any when quite yet I'm afraid since it's Version Next, but I'm planning to work on that version during my Easter vacation. I had hoped to get it out by now but... Real life... :(
  30. Exanimis Trainee Engineer

    Is it possible to make this work with visual studio code?
Thread Status:
This last post in this thread was made more than 31 days old.