1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

MOD API description

Discussion in 'Modding API' started by joeblack616, Dec 25, 2014.

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

    joeblack616 Apprentice Engineer

    Messages:
    225
    Hello fellow modders, In this topic I would like to explain you some mysteries about modding API.
    Currently I don't have access to my work computer, so I will explain some basic stuff. Later I will try to describe interfaces and methods.
    So begin with ObjectBuilders !

    As you know there is object builder for every Entity in game what it is for ?
    Object builder is used for 2 things : creating of Entity and saving of Entity . When Entity is created Init method is called and object builder is passed as parameter. From this object builder class all data is used to initialize entity.
    GetObjectBuilder method is called when game is saving. Inside this method current state of Entity is "captured" into object builder that is saved into disk. So each time you call getObjectBuilder method, you will get snapshot of current Entity state. As you see calling this method each frame is not very performance friendly because each time entire Entity is captured.

    This is also reason why changing values inside object builder doesn't alter Entity state. For actually changing Entity state, you would need to call Init method with objectbuilder that has changed values.
    That is very bad idea (to call init when Entity was already initialized). And that's reason why you don't have access to Init method on IMyEntity :D
     
    • Informative Informative x 3
  2. joeblack616

    joeblack616 Apprentice Engineer

    Messages:
    225
    But I my scripts i'm overwriting entities and I have access to initMethod !
    Actually, let see evil sensor MOD API sample:
    [MyEntityComponentDescriptor(typeof(MyObjectBuilder_SensorBlock))]
    first you are declaring that you would like to attach yourself into SensorBlock
    public class EvilSensor : MyGameLogicComponent
    now you are overriding MyGameLogicComponent component.
    What is MyGameLogicComponent ?
    Our entities consists of components, some of components are : RenderComponent, PositionComponent etc.
    Also MyGameLogicComponent is one of this components, it basically sais how Entity should behave.
    This component is created during creation of Entity. So MyGameLogicComponent is part of enitity not Entity itself.
    This is also reason why you cannot change values of enitity for which you are overriding MyGameLogicComponent.
    You don't have access to objectBuilder of Entity, only access to object builder of MyGameLogicComponent.
    {
    MyObjectBuilder_EntityBase m_objectBuilder = null;
    This is just caching of object builder, I will explain later
    static String[] OreNames;
    nothing interesting for us here
    IMySensorBlock Sensor;
    This is entity that contains our custom game logic component (in this case sensor block)

    public override void Close()
    Close is called when Entity is marked to be removed from scene
    {
    Sensor.StateChanged -= sensor_StateChanged;
    }

    public override void Init(MyObjectBuilder_EntityBase objectBuilder)
    init method is called when entity is intialized (in this case MySensorBlock)
    {
    if (OreNames == null)
    {
    MyDefinitionManager.Static.GetOreTypeNames(out OreNames);
    }
    m_objectBuilder = objectBuilder;
    here we just remember objectBuilder passed as parameter
    Sensor = Entity as IMySensorBlock;
    Enitity is property of base class of every component, it's initalized when component is created and its used for comunication between components of entity
    Sensor.StateChanged += sensor_StateChanged;
    in our case we wan't to react when sensor changes state so we suscribe our custom even to be executed when sensor change state
    }
    public override MyObjectBuilder_EntityBase GetObjectBuilder(bool copy = false)
    this is mandatory method for logic component, just return cached object builder
    {
    return m_objectBuilder;
    }
    }
     
    Last edited by a moderator: Dec 25, 2014
    • Informative Informative x 1
  3. AshleyRyder

    AshleyRyder Trainee Engineer

    Messages:
    1
    Hello, I am not sure where to post this, but since this is the description for the mod API I thought here would be an appropriate place.
    I have a problem, I have tried to find the Space Engineers MOD SDK but when following this: https://www.spaceengineersgame.com/modding.html I can not find it in my Steam Library. Any help please?
     
  4. mexmer

    mexmer Senior Engineer

    Messages:
    1,977
    i might be wrong, but i think modsdk is part of game installation now
     
  5. midspace

    midspace Senior Engineer

    Messages:
    2,224
    As it describes in the link...
    Open the Steam client.
    go to "Library" and select "Tools".
    “Space Engineers ModSDK” should be listed in the huge list of other freely available tools.
    Select and install it.

    It only appears under the "Tools" section.
    Please make sure you are in the correct section.
     
  6. mexmer

    mexmer Senior Engineer

    Messages:
    1,977
    nope, it's not there, only server. but considering content of "Tools" folder in SE installation (see my preivous post). i believe that's the same thing - it corresponds to what is mentioned in page regarding modding (mwbuilder and stuff)

    EDIT: it's only small part of SDK - see next post
     
    Last edited: Jun 17, 2015
  7. mexmer

    mexmer Senior Engineer

    Messages:
    1,977
  8. Harag

    Harag Junior Engineer

    Messages:
    913
    In addition to the tools that are also included with the default SE installation the ModSDK provides you with the editable form of some of the game's assets: .fbx files that contain Keen's models and .wav files containing audio effects. If you don't want those you currently don't need the ModSDK. The .fbx files are good reference material if you want to know what parts a certain type of block is made of, though.
     
    • Like Like x 1
  9. mexmer

    mexmer Senior Engineer

    Messages:
    1,977
    Thanks for info, i was wondering why modsdk is so huge, since tools in tools folder take quite less space
     
  10. midspace

    midspace Senior Engineer

    Messages:
    2,224
    I was going to say, you could try the Steam install link (copy and paste into an empty browser tab). Your browser may prompt you with a security warning.
    steam://install/326880

    I'd provide it as a link, except the Forums itself does not work with the "steam:" protocol and corrupts it.
    Or I could wrap it like this: https://tinyurl.com/SEModSDK
     
  11. Muppel

    Muppel Trainee Engineer

    Messages:
    16
    The bug with the missing modsdk in the tools is still present in the current versions of SE.
    So the bug is more than one year old. Maybe it's about time to fix it.
     
  12. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    there is no bug here, ModSDK no more part of the game.
     
  13. Muppel

    Muppel Trainee Engineer

    Messages:
    16
    Well all tutorials about the first steps into modding (even those from ksh) tell me that in order to get the mod sdk I shall
    And guess what ...
    And yes that is a bug.
     
  14. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    may be some steam region binding?
    cuz i have SDK here.
     
  15. Muppel

    Muppel Trainee Engineer

    Messages:
    16
    Obviously.
    But that doesn't help me. Cuz I don't have it.

    Otherwise there is a workaround. There is a sticky thread related to the bug.
    https://forums.keenswh.com/threads/modding-data-moved-to-steam-sdk.7345862/

    thank you for your efforts.
     
  16. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    i am afraid that this is more question to steam itself, then KSH.
     
  17. Muppel

    Muppel Trainee Engineer

    Messages:
    16
    Uh really? Sorry, I was not aware that KSH is not responsible for their setup and installation on steam.
    Maybe they could get "whoever is responsible" to fix it than?

    As this is already solved (in a way) and talking about it becomes more and more tedious I'll stop this conversation.
     
  18. Kokurokoki

    Kokurokoki Apprentice Engineer

    Messages:
    109
    Does anyone know where I can read up on the Mod API? Still new to modding in SE but I want to get a headstart and do some reading.
     
  19. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    what exactly you wanna read?
     
  20. Kokurokoki

    Kokurokoki Apprentice Engineer

    Messages:
    109
    Mainly remote, sensor, and beacon blocks. I'm wondering if I can write a script that allows rockets to home in on targets using custom remote blocks that serve as the targeting designator. I'm not sure if that's possible, but there's gotta be a clearer way for players to keep track of locked targets for their missiles.

    This probably isn't the right place to post it, but do modded scripts and in-game scripts use the same methods and objects? I'm assuming that they are both different, but again I'm just getting into script modding so my knowledge is still extremely limited.
     
  21. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    ModAPI=mod_access+ingame_access.
    so mods can do same as ingame, but even more.

    you can add additional properties to remote control, so you can add tracking ability to remote control block(so it will always know where it target are)
     
  22. Kokurokoki

    Kokurokoki Apprentice Engineer

    Messages:
    109
    Would it be possible to link that with rocket launchers then too? I'm assuming that's the part where mod access scripting has an advantage over in-game scripting.

    If you don't mind, I'll probably take a look at one of your scripts to see what the definitions are and then post questions later if I have any issues.
     
  23. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    yes, property can also be added to them, or you mean targeted missiles(As build-in weapon)? cuz second is harder, i don't remember about them.
    my scripts? you mean my mod? ok look, it have only script, no definitions.
     
  24. Kokurokoki

    Kokurokoki Apprentice Engineer

    Messages:
    109
    Alright thanks. Is there a place where I can look at the mod API definitions?

    There's a mod on the workshop that kinda manages to do it, so I'm going to take a look there and see what I can do.
     
  25. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    for mod scripting better just use IDE, it will help a lot.

    if you mean data definitions(sbc files), just look at originals from game.
     
    • Informative Informative x 1
  26. Cursedth

    Cursedth Apprentice Engineer

    Messages:
    111
    • Informative Informative x 1
Thread Status:
This last post in this thread was made more than 31 days old.