This item has been removed from the community because it violates Steam Community & Content Guidelines. It is only visible to you. If you believe your item has been removed by mistake, please contact Steam Support.
This item is incompatible with Space Engineers. Please see the instructions page for reasons why this item might not work within Space Engineers.
Current visibility: Hidden
This item will only be visible to you, admins, and anyone marked as a creator.
Current visibility: Friends-only
This item will only be visible in searches to you, your friends, and admins.
Space Engineers Modding API Guide
By Marek Rosa
This guide will tell you how to start with our new Modding API and get it in your game
Important note Shortly after releasing the API we will be doing some large changes to the codebase. Basic API gateway should remain compatible, but for blocks there will be probably change in the way you access and use them. Logic will stay the same you will probably just need to rename/ add some functions to get to the entities.
Basic setup for writing a script Create new project in your favorite IDE (we use VS2012) It does not matter what kind of project you create since you will not be compiling the code, you will use the IDE just for intelisense and highlighting. Reference our libraries that can be found in Bin folder of your game (architecture does not matter since again its just for) You can try start fresh or download some of usecase or other players script.
Entry point To get anything from game you should go through interfaces provided by Sandbox.ModAPI.MyAPIGateway
Most of thing you get this way will be in form of interface, they are not complete though, they serve more like a filter to what you can access so implementing let’s say IMyEntity and trying to pass it to game will fail.
Getting your code executed There are several ways to this You add handler on MyAPIGateway.Utils.MessageEntered and execute your code depending on player input to chat You can subclass MySessionComponentBase, add Attribute and it will get loaded before world and then updated each frame. You can subclass MyGameLogicComponent, add Attribute and it will get hooked to any object
Where to put files In your Space engineers Mods folder create a new folder with name of your mod with structure like this Mods\YourMod\Data\Scripts\YourScript\ And put all the .cs files in YourScript folder
Debugging your code For now the debugging options are limited, after loading mod with script you can see F11 screen for any compilation or restriction errors. While debugging you can wrap all your code in try-catch blocks and write any exceptions to custom log file so your game does not crash each time something goes wrong.
There will be at least three levels for scripting. Dlls, Scripts as mods and Ingame scripting. Currently you are looking at the middle of these and since they are to be distributed by workshop we cannot risk someone wiping drives or downloading trojans and because you cannot possibly blacklist every way to the system we decided for whitelisting, that means if method/ class / namespace(bound to actual dll) is not whitelisted you cannot use it. For the dlls there should be no such restrictions as they will be distributed the way community API was. On the contrary Ingame scripting will be highly restricted since anyone will be able to write it at runtime. Preview of these is ModAPI.Ingame
Details Few things you might find yourself fiting with. First of them will be our internal object names. Object builder - storing structure used for serializing and deserializing object states. CubeGrid - Large/small ship, station. SlimBlock - base for all blocks used for memory optimization. Armors, catwalks, ramps and similar have only this. FatBlock - more complex blocks with some logic or functionality - Door, Refinery, Piston and others have this in addition to