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.

Space Engineers ModAPI Feature Requests

Discussion in 'Modding' started by rexxar, Oct 10, 2017.

  1. midspace Senior Engineer

    Messages:
    2,203
    I cannot believe...
    Code:
    The type or member 'The type or member 'SerializableBoundingSphereD' is prohibited
    It's in the VRage.Serialization namespace.

    And yet, SerializableBoundingBo:woot: in the VRage namespace is perfectly fine to use.

    I'm probably asking you to poke a stick in a hornets nest to look at that one.
    Surely there is a better way for me to serialise some data into binary using the game's existing base `Serializable` classes and structs rather than copying them to my own project?
    --- Automerge ---
    Please see if you can add it to the whitelist.
     
  2. midspace Senior Engineer

    Messages:
    2,203
    Add the following ProtoBuf Attributes to the whitelist.
    They allow the method with the specified attribute to be invoked automatically during serialization and deserialization by ProtoBuf.
    • ProtoBuf.ProtoBeforeSerializationAttribute
    • ProtoBuf.ProtoAfterSerializationAttribute
    • ProtoBuf.ProtoBeforeDeserializationAttribute
    • ProtoBuf.ProtoAfterDeserializationAttribute
     
  3. Digi Senior Engineer

    Messages:
    2,252
    • A way to get mod session component(s) through MyAPIGateway (just like block.GameLogic.GetAs<T>() but for session components).
    • Ability to get and overwrite a block's terminal-only-name (just like all blocks have "(Incomplete)", "(Access denied)" or thrusters have "(Forward)", etc appended to them).
    • Adding to ^ it would also be nice if we can get and overwrite the color and font they show up as (which is supported, see: MyTerminalControlPanel.UpdateItemAppearance()).
     
  4. midspace Senior Engineer

    Messages:
    2,203
    The only way to do this currently is with this mess and the ObjectBuilder for the component.

    Code:
    var cpnt = MyAPIGateway.Session.GetCheckpoint("null");
    MyObjectBuilder_SectorWeatherComponent weatherComp = null;
    foreach (var comp in cpnt.SessionComponents)
    {
    	MyObjectBuilder_SectorWeatherComponent component = comp as MyObjectBuilder_SectorWeatherComponent;
    	if (component != null)
    		weatherComp = component;
    }
     
  5. rexxar SE Programmer Staff

    Messages:
    1,522
    Those are not available on purpose.
     
  6. Digi Senior Engineer

    Messages:
    2,252
    @midspace
    I mean your own mod defined session components, to avoid needing a static instance pointer to access it.
    The useful stuff from game's session components can be exposed individually.
     
  7. midspace Senior Engineer

    Messages:
    2,203
    Is there any particular reasoning behind why they cannot be made available that you can share with us?
     
  8. rexxar SE Programmer Staff

    Messages:
    1,522
    I decided they were unsafe, but I can't remember the exact details. Probably something to do with how and when the code was being executed, allowing you to break out of the session.
     
  9. midspace Senior Engineer

    Messages:
    2,203
    * Add text to the EchoText field in the Programmable Block via the ModAPI.
    * Clear the EchoText field in the Programmable Block via the ModAPI.
    --- Automerge ---
    When the game backs up data, it needs to backup the "Storage" path too for any files previously written with the WriteFileInWorldStorage().

    Currently, if a mod fails to load, and an automatic save is made, then any files in the Storage Path are lost.
     
  10. midspace Senior Engineer

    Messages:
    2,203
    To be able to use either of the following calls from ModAPI, the VRage.Audio namespace needs to added into the Roslyn mod compiler.

    Code:
    Sandbox.Game.MyVisualScriptLogicProvider.PlayHudSound(0, player.IdentityId);
    Sandbox.Game.MyVisualScriptLogicProvider.PlayHudSound(MyGuiSounds.HudClick, player.IdentityId);
    This is a simpler access to playing Hud sounds to the player then creating a 3DSoundEmitter to a specified entity.

    Code:
    MOD_ERROR: SystemTester, in file:
    
    Compilation of C:\Users\CaptainJack\AppData\Roaming\SpaceEngineers\Mods\SystemTester_SystemTester failed:
    MOD_ERROR: SystemTester, in file:
    C:\Users\CaptainJack\AppData\Roaming\SpaceEngineers\Mods\SystemTester\Data\Scripts\SystemTester\AttachmentBuilder_v3.cs(221,16): Error: The type 'MyGuiSounds' is defined in an assembly that is not referenced. You must add a reference to assembly 'VRage.Audio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
     
  11. Equinox Trainee Engineer

    Messages:
    7
    Access to MyPlayerCollection.PlayersChanged (or a new event, MyPlayerCollection.PlayerAdded) and MyPlayerCollection.PlayerRemoved. The Visual Scripting events fire before the actual player is added/removed which means that you have to defer looking up the actual player object -> a huge pain. Also +1 for Digi's request of TryGetPlayerBySteamId and TryGetPlayerByIdentityId. These should either always assume SerialId = 0, or the serial identities should be exposed properly.
     
  12. midspace Senior Engineer

    Messages:
    2,203
    @Equinox after the VisualScript event PlayerConnected has fired, it should be in the list of player Identities.

    Code:
    		public static bool TryGetIdentity(this IMyPlayerCollection collection, long identityId, out IMyIdentity identity)
    		{
    			var listIdentites = new List<IMyIdentity>();
    			MyAPIGateway.Players.GetAllIdentites(listIdentites, p => p.IdentityId == identityId);
    			identity = listIdentites.FirstOrDefault();
    			return identity != null;
    		}
     
  13. Equinox Trainee Engineer

    Messages:
    7
    Note I said Player not Identity.
    Code:
    		private void AddPlayer(MyPlayer.PlayerId playerId, MyPlayer newPlayer)
    		{
    			if (Sync.IsServer && MyVisualScriptLogicProvider.PlayerConnected != null)
    			{
    				MyVisualScriptLogicProvider.PlayerConnected(newPlayer.Identity.IdentityId);
    			}
    			newPlayer.Identity.LastLoginTime = DateTime.Now;
    			newPlayer.Identity.BlockLimits.SetAllDirty();
    			this.m_players.Add(playerId, newPlayer);
    			this.OnPlayersChanged(true, playerId);
    		}
    
     
  14. douxt Trainee Engineer

    Messages:
    38
    the method below in IMyProjector should be able to set builtBy info for the block created. Since the block limits use BuiltBy to count block numbers, this could be very useful.

    void Build(VRage.Game.ModAPI.IMySlimBlock cubeBlock, long owner, long builder, bool requestInstant);

    the "builder" parameter should be documented as an entity ID, not an identity.


    and @Equinox pointed out the difference between the internal and mod api methods:

    Code:
    public void Build(MySlimBlock cubeBlock, long owner, long builder, bool requestInstant = true, long builtBy = 0L);
    
    void Sandbox.ModAPI.IMyProjector.Build(VRage.Game.ModAPI.IMySlimBlock cubeBlock, long owner, long builder, bool requestInstant)
    {
    this.Build((MySlimBlock)cubeBlock, owner, builder, requestInstant, 0L);
    }
     
    Last edited: Dec 14, 2017
  15. Digi Senior Engineer

    Messages:
    2,252
    • Since MyGamePruningStructure will not be accesible, make the API entity methods not *return* lists and allow us to supply our own (like MyAPIGateway.Entities.GetTopMostEntitiesInSphere())
    And while you can have an internal persistent list to be returned I don't really recommend that as people will keep that list to re-use it and then be surprised when their list is suddenly empty or has different objects when another mod uses it as well.
    • ^ also, MyGamePruningStructure's methods have separate dynamic and static requests (MyEntityQueryType), that would be useful to have access to that as well in the cases where we only want static entities or just dynamic ones.
     
    Last edited: Dec 31, 2017
  16. midspace Senior Engineer

    Messages:
    2,203
    Add the following interface methods for Gas Tanks so we can arbitrarily add or remove gas.
    * Sandbox.ModAPI.IMyGasTank.Fill(float amount)
    * Sandbox.ModAPI.IMyGasTank.Drain(float amount)
     
  17. rexxar SE Programmer Staff

    Messages:
    1,522
    Just use the ResourceSourceComponent and call SetRemainingCapacityByType
     
  18. midspace Senior Engineer

    Messages:
    2,203
    Does not work.
    Testing in offline game. Started with a half full gas tank. Setting the capacity to 0, the Tank's visual indicators do not change. The Display Text in the control panel does not change.
    Discuss in discord if you want more details.
     
    Last edited: Jan 1, 2018
  19. Phoera Senior Engineer

    Messages:
    1,711
    not enough, to redraw emissives he may call UpdateVisuals(directly or via changing enabled/disabled if not avaliable).
    also he need request text update as well.

    may be better add easy method? :)
     
    • Agree Agree x 1
  20. Phoera Senior Engineer

    Messages:
    1,711
    i wanna access to gravity system as well.
    logical step after atmo/oxy one.
    interface for provider is inside already, just need give ability to add it.
     
  21. Phoera Senior Engineer

    Messages:
    1,711
    • whitelist for CallerLineNumber, CallerMemberNameAttribute, CallerFilePathAttribute attributes.
    very usefull for debug and logging, cannot harm at all.
     
  22. Digi Senior Engineer

    Messages:
    2,252
    • A getter for the light object (MyLight) from lighting blocks.
    • A way to disable the vanilla light object on lighting blocks (to avoid the mod having to fight with the game to turn it off).
     
  23. midspace Senior Engineer

    Messages:
    2,203
    * Add BuiltBy to VRage.Game.ModAPI.IMySlimBlock
     
  24. Digi Senior Engineer

    Messages:
    2,252
    That exists already. https://i.imgur.com/i5ZUutN.png
     
  25. midspace Senior Engineer

    Messages:
    2,203
    I was testing in the SVN codebase, and it wasn't there. It must be old code. :(
     
  26. BAM5 Trainee Engineer

    Messages:
    2
    Looks like this thread is open to requests for ModAPI.Ingame as well so...

    The ability to get the same signal information that is available on the player hud via a radio type antenna. Such as Name & world position vector, also type of signal/affiliation? Not sure what it is that changes the colors of the font on the hud.

    For Sandbox.ModAPI.Ingame.IMyOreDetector have the ability to to retrieve what ores are currently being detected. For extra brownie points also the world position vectors of those ores! :D
     
  27. Digi Senior Engineer

    Messages:
    2,252
  28. midspace Senior Engineer

    Messages:
    2,203
    The current CreateAreaTriggerOnPosition(...) only allows a trigger area that is a sphere.
    There appears to be code in MyTriggerComponent to allow a box trigger (MyTriggerComponent.TriggerType.AABB), but it hasn't been fully implemented.
    I had a go of trying to fill in the gaps within a mod, however one part, MyTriggerAggregate is not whitelisted.

    * Create a variant of MyAreaTriggerComponent that uses TriggerType.AABB instead of TriggerType.Sphere (Box instead of sphere trigger)
     
  29. Anonymous Blackness Trainee Engineer

    Messages:
    7

    So is there Toolbar access yet? I'd like my mod to be able to read which weapon is selected from the cockpit or remote control blocks
     
  30. Digi Senior Engineer

    Messages:
    2,252
    Nothing was added regarding toolbars API, but...

    You can read a block's toolbar by using block.GetObjectBuilderCubeBlock() and cast it to the block's objectbuilder type (e.g. MyObjectBuilder_RemoteControl), then you can access the toolbar objectbuilder there.
    And since that creates a class instance every time it's called, don't do it frequently.

    The player toolbar is unreadable, you can do some stuff using some toolbar methods from MyVisualScriptLogicProvider though.
     
    • Informative Informative x 1