Space Engineers

Space Engineers

42 ratings
Dispenser - ModAPI example
   
Award
Favorite
Favorited
Unfavorite
Type: Mod
Mod category: Block, Script
File Size
Posted
Updated
335.401 KB
18 Sep, 2014 @ 9:26am
25 Nov, 2014 @ 9:20am
5 Change Notes ( view )

Subscribe to download
Dispenser - ModAPI example

Description
Usage:
1) Build sensor
2) Name it like 'UraniumXX' or 'IronYY'
3) When you enter sensor, it will spawn ore specified in name

This is example how to use ModAPI, download the mod, rename to zip and browse to see how it's done.
Feel free to reuse the code in your mods.

EDIT:
There's video showing how to setup Visual Studio (with autocomplete!) and create mod similar to this:
https://www.youtube.com/watch?v=gAh1bNfRLPw
24 Comments
sssagatt 12 Jan, 2020 @ 2:30am 
Is this still works to somebody? I tried to make it same way as the video showes, but in Visual Studio there is not going to be blue some text which should: "mygamelogiccomponent"; "MyObjectBuilder_EntityBase". And also I can't found "VRage.Common.dll".
TheWorkingMan43 20 Jan, 2016 @ 1:49am 
Ore that you already have or free no mining ore?
Smokie 28 Dec, 2014 @ 2:25pm 
Mod no longer works.
BlazR 10 Nov, 2014 @ 2:11am 
I've made a few modifications and got a working version. For those who just want to use it for the dispenser function, I've published the working version here along with the patches in the changelogs so you can see how I modified the code.
Ferro 4 Nov, 2014 @ 7:05am 
Yeah this thing no longer works with the current version of Space Engineers
DeltaF1 28 Oct, 2014 @ 2:17pm 
@Hugo
Instead of throwing a NullReference, you can slo just do "return null;"
I got caught on that method too, and someone on youtube had to show me XD
Hugo the Dwarf 26 Oct, 2014 @ 11:09am 
Guess I figured it out, kinda.

public override MyObjectBuilder_EntityBase GetObjectBuilder(bool copy = false)
{
throw new NullReferenceException();
}

removes the errors and lets my code run now.
Hugo the Dwarf 26 Oct, 2014 @ 11:03am 
As of posting 26/10/2014, The example code in the video does not work, I do however checked my debug menu and found I had a few errors,

AppData\Roaming\SpaceEngineers\Mods\MyFirstMod\Data\Scripts\TestScript\TestScript\EvilSensor.cs(20,18) : error CS0534: 'TestScript.EvilSensor' does not implement inherited abstract member 'Sandbox.Common.Components.MyGameLogicComponent.GetObjectBuilder(bool)'

And when I impliment or override this method I'm not sure what to return for "MyObjectBuilder_EntityBase" I am brand new to this, and would love to start scripting for this game.
Davcrox 18 Oct, 2014 @ 3:02am 
not working in the last version of the game
Raszagal 12 Oct, 2014 @ 10:04am 
@CBFasi: it does still work, you need to move close and back out as the sensor needs to change it's state as shown by the color of it's display