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.

Modding API - changes in modding interface

Discussion in 'Modding API' started by joeblack616, Oct 22, 2014.

Thread Status:
Not open for further replies.
This last post in this thread was made more than 31 days old.
  1. joeblack616 Apprentice Engineer

    Messages:
    225
  2. tyrsis Junior Engineer

    Messages:
    862
    Did you fix the sync on AddEntity / CreateFromObjectBuilderAndAdd ?
     
  3. joeblack616 Apprentice Engineer

    Messages:
    225
    Hi,
    not yet. I will look at it next week.
     
  4. joeblack616 Apprentice Engineer

    Messages:
    225
    added :

    bool FileExistsInGlobalStorage(string file);
    bool FileExistsInLocalStorage(string file, Type callingType);
    void DeleteFileInLocalStorage(string file, Type callingType);
    void DeleteFileInGlobalStorage(string file);
    into myutilities
     
  5. Ravenal Apprentice Engineer

    Messages:
    362
    Perfect this will work great!

    Is there a possibility that we could create folders within our own mod folder? Or no?
     
  6. joeblack616 Apprentice Engineer

    Messages:
    225
    added void SendEntitiesCreated(List<Sandbox.Common.ObjectBuilders.MyObjectBuilder_EntityBase> objectBuilders) into IMyMultiplayer.

    when you create new grid it's your responsibility to sync it with others.

    @Uniphix: You cannot create directories in your mod folders. You can create only files.
    You know, we are paranoid.;)
     
    Last edited by a moderator: Nov 12, 2014
  7. joeblack616 Apprentice Engineer

    Messages:
    225
    Hi, please have in mind that you are sending object_builder to synchronize not cubeGrid (e.g. you need to set position in builder not grid).
    I will provide updated version for loading and saving grids script after update.
     
    Last edited by a moderator: Nov 12, 2014
  8. tyrsis Junior Engineer

    Messages:
    862
    Now can you just add a quick SendEntitiesUpdated() when you modify something and want it synced for everyone? And there will be much fanfare (from me)
     
  9. Ravenal Apprentice Engineer

    Messages:
    362
    Yes I know you guys are paranoid, but that is good thing though, it tells us you are concern for your community's security. And I and I am sure among many others appreciate that.

    I have found other ways to work around my issue, what I've done is added the name of the save game into my file structure so that its a unique file for each of the save game. Unless I don't understand how that works, does it create a new Storage File for each of the save game? If so then I will know what I need to do.
     
  10. Ravenal Apprentice Engineer

    Messages:
    362
    Is this referred to any type of Multiplayer? As Offline works different than the others?
     
  11. joeblack616 Apprentice Engineer

    Messages:
    225
    Hi,
    I'm afraid SendEntitiesUpdated can't be done, could you please write what exactly would you like to achieve ?
     
  12. tyrsis Junior Engineer

    Messages:
    862
    I'd like things to sync in multiplayer. If you set displayname, customname, _anything_. Nothing syncs. Try it in mulltiplayer. It makes modapi almost useless in dedicated and multiplayer. The only thing that syncs is movement, and maybe the terminalactions. But that is limited to turning things on and off basically.

    Here are things I need to sync (and even set in some cases):
    Any sort of text name (displayname of grid, customname of blocks) - Right now setting this only happens on the client setting it, not synced
    Integrity - Can't even set this right now?
    Buildpercent - Can't even set this right now?
     
  13. joeblack616 Apprentice Engineer

    Messages:
    225
  14. midspace Senior Engineer

    Messages:
    2,224
    Joe, I have finally had a chance to look at SendEntitesCreated, and found a small issue when syncing a FloatingItem on a Dedicated server.

    On the client, two items appear to be created, but only one can be interacted with.
    The two items do appear to collide with one another on the client.

    You can test this in my command script mod, in the DropCommand.cs
    In game, open the chat console and type "/drop steel pla 10".
    http://steamcommunity.com/sharedfiles/filedetails/?id=316190120
     
  15. BlazR Trainee Engineer

    Messages:
    22
    I had this issue on a dedicated server with
    Code:
    var floatingObject = Sandbox.ModAPI.MyAPIGateway.Entities.CreateFromObjectBuilderAndAdd(floatingBuilder);
    
    It would spawn 2 objects, one interactable, the other not (most likely because the server didn't recognize the client spawned object)

    I got around it by adding
    Code:
    if (!Sandbox.ModAPI.MyAPIGateway.Multiplayer.IsServer) return;
    

    It doesn't seem to affect SP functionality. I'm guessing because on local worlds the client IS the server, so Sandbox.ModAPI.MyAPIGateway.Multiplayer.IsServer returns true.

    Don't know if it'll help in this case, but I figured I'd mention it at least.
     
  16. Gwindalmir Senior Engineer

    Messages:
    1,004
    Not syncing related, but I found that the VRageMath.Vector3D.CreateFromAzimuthAndElevation method doesn't output a Vector3D, only a Vector3.

    PS. I'm happy that it looks like some syncing is now possible, I'll have to experiment with it.
     
    Last edited by a moderator: Nov 15, 2014
  17. joeblack616 Apprentice Engineer

    Messages:
    225
    added Sandbox.Common.ObjectBuilders.MyObjectBuilder_SessionSettings SessionSettings { get;} into IMySession
     
  18. midspace Senior Engineer

    Messages:
    2,224
    No. It does not help.

    When playing on a Dedicated server the mod is running on both the Server and Client computers. The mod is initiated only on the Client computer by using a chat command.

    Doing a Multiplayer.IsServer is pointless for me, as the item can only be generated by a User initiated command. The mod running on the server is incapable of ever receiving such a command.

    The Floating item is only created on the client computer, and then synchronized to the server.
    I use practically the same code to generate a CubeGrid (Ship) and Meteors.
    Only the Floating Item appears to create a duplicate.

    Of course it doesn't affect SP functionality, the issue is with the synchronising the new Floating Item to the server.
     
  19. joeblack616 Apprentice Engineer

    Messages:
    225
    Hi all ,
    today it will be quite long post.

    I added

    void ShowMissionScreen(string screenTitle = null, string currentObjectivePrefix = null, string currentObjective = null, string screenDescription = null, Action<ResultEnum> callback = null, string okButtonCaption = null);

    IMyHudObjectiveLine GetObjectiveLine();

    into IMyUtilities

    also added new Interface :


    public interface IMyHudObjectiveLine
    {
    bool Visible { get; }
    string Title { get; set; }
    string CurrentObjective { get; }
    void Show();
    void Hide();
    void AdvanceObjective();
    List<string> Objectives
    {
    get;
    set;
    }
    }


    What does it do ? ShowMissionScreen will show following dialog :

    [​IMG]

    What you can mod :
    1 - screenTitle
    2 - currentObjectivePrefix
    3 - currentObjective
    4 - screenDescription
    5- okButtonCaption

    What you cannot mod:
    Screen size/position/texture/layout (this doesn't mean that we will not allow it in future ;) )

    callback method is called when user closes dialog. ResultEnum can have two values :
    Ok - when user pressed ok button or CANCEL - when user pressed close or Escape. You can use this screen for display to user any information you want.


     
  20. joeblack616 Apprentice Engineer

    Messages:
    225
    IMyHudObjectiveLine is used for this :
    [​IMG]
    It will show objective title and description in middle top screen.(only when HUD is shown.)

    At beginning of script you can set Title property to show title and then insert objective description into Objectives property. After that you can change current objective with AdvanceObjective method. You can also Show and Hide objective line (default state is hidden). There is support only for one line of text for now. Also you can use this for providing any information to player, not only objectives.
     
  21. Vdragon Apprentice Engineer

    Messages:
    326
    Nice! Dialog boxes!
     
  22. eobando Trainee Engineer

    Messages:
    96
    Whoa!!!! Joe, this is beautiful!!!
     
  23. tyrsis Junior Engineer

    Messages:
    862
    Can we have a state object in here that is returned with the Result ie:
    void ShowMissionScreen(string screenTitle = null, string currentObjectivePrefix = null, string currentObjective = null, string screenDescription = null, Action<ResultEnum> callback = null, string okButtonCaption = null, object state = null);

    And when a button is pressed, the state object is returned in the callback along with the result? That way we can pass user defined data to this dialog, as it appears to just be all strings

    Also what happens when multiple ShowMissionScreen's go up? Is that allowed? Can you expand on this a bit more? If not allowed to have more than 1, can we detect if one is up? Also if more than 1 are allowed, how does that work?
     
  24. Ravenal Apprentice Engineer

    Messages:
    362
    agreed!
     
  25. joeblack616 Apprentice Engineer

    Messages:
    225
    Hi all,
    yes you can have more than one dialog box on screen (although they will be blended and will look pretty bad).
    I will consider adding state as you requested. Meanwhile :

    added :
    public interface IMyFactionCollection
    {
    bool FactionTagExists(string tag, IMyFaction doNotCheck = null);

    bool FactionNameExists(string name, IMyFaction doNotCheck = null);

    IMyFaction TryGetFactionById(long factionId);
    IMyFaction TryGetPlayerFaction(long playerId);

    void AddPlayerToFaction(long playerId, long factionId);

    void KickPlayerFromFaction(long playerId);

    Sandbox.Common.MyRelationsBetweenFactions GetRelationBetweenFactions(long factionId1, long factionId2);

    bool AreFactionsEnemies(long factionId1, long factionId2);

    bool IsPeaceRequestStateSent(long myFactionId, long foreignFactionId);
    bool IsPeaceRequestStatePending(long myFactionId, long foreignFactionId);

    void RemoveFaction(long factionId);

    void SendPeaceRequest(long fromFactionId, long toFactionId);
    void CancelPeaceRequest(long fromFactionId, long toFactionId);
    void AcceptPeace(long fromFactionId, long toFactionId);
    void DeclareWar(long fromFactionId, long toFactionId);


    void SendJoinRequest(long factionId, long playerId);
    void CancelJoinRequest(long factionId, long playerId);
    void AcceptJoin(long factionId, long playerId);

    void KickMember(long factionId, long playerId);
    void PromoteMember(long factionId, long playerId);
    void DemoteMember(long factionId, long playerId);
    void MemberLeaves(long factionId, long playerId);

    event Action<long, bool, bool> FactionAutoAcceptChanged;

    void ChangeAutoAccept(long factionId, long playerId, bool autoAcceptMember, bool autoAcceptPeace);

    event Action<long> FactionEdited;

    void EditFaction(long factionId, string tag, string name, string desc, string privateInfo);

    void CreateFaction(long founderId, string tag, string name, string desc, string privateInfo);

    event Action<long> FactionCreated;

    Sandbox.Common.ObjectBuilders.MyObjectBuilder_FactionCollection GetObjectBuilder();
    }

    public interface IMyFaction
    {
    long FactionId { get; }

    string Tag { get; }
    string Name { get; }
    string Description { get; }
    string PrivateInfo { get; }

    bool AutoAcceptMember { get; }
    bool AutoAcceptPeace { get; }

    bool IsFounder(long playerId);

    bool IsLeader(long playerId);

    bool IsMember(long playerId);

    bool IsNeutral(long playerId);


    VRage.Collections.DictionaryReader<long, MyFactionMember> Members { get; }
    VRage.Collections.DictionaryReader<long, MyFactionMember> JoinRequests { get; }
    }

    added :
    IMyFactionCollection Factions { get;}
    into IMySession.
     
  26. Ravenal Apprentice Engineer

    Messages:
    362
    *claps* This is something I am sure A LOT of modders have been waiting for. I am one of them...
     
  27. joeblack616 Apprentice Engineer

    Messages:
    225
    Yes, I know :)
    Hi guys, today I realized that probably I didn't answer all you PM's about modding. If so, could you please write me your unanswered questions again ? So I can keep track of what is still open. Thanks.
     
  28. Ravenal Apprentice Engineer

    Messages:
    362
    Code:
    BinaryReader ReadBinaryFileInGlobalStorage(string file);
     
        BinaryReader ReadBinaryFileInLocalStorage(string file, Type callingType);
     
        BinaryWriter WriteBinaryFileInGlobalStorage(string file);
     
        BinaryWriter WriteBinaryFileInLocalStorage(string file, Type callingType);
    
    Was added today in 01.059, although I found out that it looks like they forgot to add BinaryWriter and Reader to the Whitelist.
     
  29. joeblack616 Apprentice Engineer

    Messages:
    225
    Hi, sorry guys,
    it will be fixed today.
     
  30. InfiniteDice Trainee Engineer

    Messages:
    49
    IMyTurret??? :)
     
Thread Status:
Not open for further replies.
This last post in this thread was made more than 31 days old.