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 - new requests

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. Ravenal Apprentice Engineer

    Messages:
    362
    Hey Joe,

    Is this possible, it would help us know who sent the message in chat especially if it is for Dedicated Server.

    in IMyUtilities.MessageEntered event;

    Add

    Code:
    public delegate void MessageEnteredDel(IMyPlayer sender, string messageText, ref bool sendToOthers);
    
    or use IMyNetworkClient and add IMyPlayer sender who sent the message or typed the message, because...

    MyAPIGateway.Session.Player will be null in Dedicated Server, and it only gets the current player that is in session, of course MyAPIGateway.Session.Player is set for servers that are ran on personal computers. So each client would be handling the message separately, but not for a dedicated server.

    Is this possible, I think others will also + my request.
     
  2. Sp[a]cemarine Apprentice Engineer

    Messages:
    101
    Of course! :D
    I wasn't sure about it was seen because I posted it only some minutes before you answered on my request and then sometimes people just miss the "ninja like" post. Since it was never mentioned, I just thought, it may be missed.

    I was reflecting a little bit about the GUI access and had an idea that might be interesting for others as well. I don't know exactly if it is possible by now but I didn't find it in the API. How about making the key bindings accessible? In connection with GUI access it can be very useful. I could just add an method on the event that's called by pressing a certain key (just an example how it could be used), that opens a screen like the "G-screen" or does other tasks. The possibilities are endless. And for us modders it is very useful if we want to make some configs that should be easily changed by the users. In my case for my Command-Tools I could just make a screen and don't have to use the chat any longer.
    Another thought was that you may add the path of the storage of the files of the mod to 'IMyGamePaths'. I know that I can just use 'MyAPIGateway.Utilities.GamePaths.UserDataPath + "\\Storage\\Id.sbm_ModName";' but I don't like that way. It's just that I store logs, debug and error data there and if some error occurs, I ask the user to provide me the file with the error and I show him the path where he finds the logs. It's not very important but it would be nice to have it.
    And a third request that's not really concerning the API itself but I don't know where else to put it. How about a topic for Q&A/Discussion concerning the API? Something like that was a bit in the "broken things" topic. From upcoming questions you could create a FAQ that might partly replace the missing documentation. I think there is a demand for that because I was asked to add more comments into my code that other people could learn from it. :D If you intend to make such a thread please don't forget that there are too much sticky posts here in the 'Modding' area.

    At last I just want to say that even without documentation it is fun to work with the API and I really appreciate your work. Keep up the great work you are doing!

    ________

    @Uniphix I think that the method only is called when the client itself sends a message (correct me if I'm wrong or I don't get what you want :D). That means that it wouldn't be called on a DS until the DS sends a message. But if I get what you really want is an event for incoming messages. That would really be nice, just for chat logging on DS for example and you could also make the server do sth. I'd say it's an interesting idea. I like it.
     
  3. Ravenal Apprentice Engineer

    Messages:
    362
    Hello I think it will be a benefit that when you add a mod to workshop that you can add stuff to be installed in both Local or Global storage.

    This is what I suggest:

    Add an xml file inside of the main mod folder (your mod) just like thumb.jpg etc. In the XML file you will add entries that will be move files from a directory in that mod of course it has to be inside that mod folder structure for example can't move a DLL in C:\Windows folder to the storage that would be well not good. But just have it be relative path ie "InstallFiles/settings.ini" or something of that sort to give you a basic idea.

    Only Install it if the file doesn't exist in that storage (so it doesn't override it of course).

    Like lets say I have a Text File that contains a list of data that can be read, since XML and Json or Binary is and cannot happen yet. We may need to and want to disrupt without having to use Code to output a file that is used. Like settings, etc. you name it i really think this would be a benefit for all modders out there...

    Another note, I think it will be a benefit to be able to delete storage files that you created so that way if you need to update something that no longer needs to exists etc.

    From there we can then in the install data have something like

    Code:
    <StorageFiles>
       <StorageFile File="settings.ini" IsLocal="True" />
       <StorageFile File="install-001.ini" IsLocal="True" MoveOnce="True" />
       <StorageFile File="install-002.ini" IsLocal="True" MoveOnce="True" />
       <StorageFile File="install-003.ini" IsLocal="True" MoveOnce="True" />
    </StorageFiles>
    Etc.

    I can add more install files etc. and when it is installed i can remove it... Therefore making modding scripting easier. Also INI is just an example, maybe you have xml files, json files, binary files that act like serialized databases etc.

    So for example in Settings.ini i would have an entry Version=001, and then when i update to 003 it will be Version=003, then I can remove the 3 install ini files in the Storage that is not there so that it doesn't take unneeded space.

    IsLocal (Optional) = Determines whether Local or Global Storage
    MoveOnce (Optional) = Determines whether or not that even if the file no longer exists in the storage that it doesn't add it again

    This should be an easy adding this.

    And in the MyAPIGateway Utilities we can do something like Reinstall( string file );

    This would allow us to do something like Utilities.Reinstall( "install-001.ini" ); if we need to have it be reinstalled from the storage install files...

    Other functions as

    Code:
    Utilities.DeleteLocalStorageFile( string file )
    Utilities.DeleteGlobalStorageFile( string file )
    
    Utilities.LocalFileExists( string file )
    Utilities.GlobalFileExists( string file )
     
  4. midspace Senior Engineer

    Messages:
    2,224
    I have mentioned this before, but since this is a thread for requests. :rolleyes:

    One of the critical API's we are still waiting on, is a check for who is a Admin on a Dedicated Server.

    This appears to work for a hosted game (I think, since I don't have two accounts).
    Code:
    MyAPIGateway.Multiplayer.IsServerPlayer(MyAPIGateway.Session.Player.Client))
    
    But we lack that IsAdmin().
     
  5. Sp[a]cemarine Apprentice Engineer

    Messages:
    101
    You are completely right!
    I'm waiting for this since I started developing my mod.
     
  6. eobando Trainee Engineer

    Messages:
    96
    Hey Joe,

    A quick question. Is the method Close() called when an auto-save is triggered? If so, how can I check when the auto-save is triggered? Your help is appreciated.
     
  7. Ravenal Apprentice Engineer

    Messages:
    362
    Any save for that matter would be good. I need this so that I can save database files and what not. Whether server save, manual save, client save, you name it if they execute save then I would like it to have some sort of event to let us wrap with.

    +1 for this.
     
  8. joeblack616 Apprentice Engineer

    Messages:
    225
    Hi, I will take a look on saving and let you know, also I will check IsAdmin for DS
     
    Last edited by a moderator: Nov 7, 2014
  9. joeblack616 Apprentice Engineer

    Messages:
    225
    BTW. did you guys tried Parallel library yet ?
    If so, some feedback would be nice.
     
    Last edited by a moderator: Nov 7, 2014
  10. Ravenal Apprentice Engineer

    Messages:
    362
    Not yet, I will be doing some soon =)
     
  11. Ravenal Apprentice Engineer

    Messages:
    362
    Hey Joe, question. If I put the I Work stuff in a loop like an update call for like handling all of the Drone Thinking and Mainframe Thinking will that be possible?
     
  12. eobando Trainee Engineer

    Messages:
    96
    Likewise. The script I am working on at the moment needs some serious re-writes. I believe the parallel lib will aid it in performance and lessen the complexity. I will definitely post once I have something tested.
     
  13. Sp[a]cemarine Apprentice Engineer

    Messages:
    101
    Hey,

    Today I spent some time on figuring out how the library works and what I can do with it. I must admit that I don't really know how I can use 'VRage.FastResourceLock' so I had some problems with two workers at one time when they both try to show an notification. After such a short time, I can't really assess it, but right now I think it is quite good. Some things may be unclear or lack but all in all it's good for the 1st revision in the ModAPI. When I speak of missing things, I refer to the thread states. They are quite useful because at the moment to create a loop that pauses for a short time, I have to create a while statement and check each time if a certain time passed. There may be other ways but it was my first idea of solving this without additional methods from IWorker or sth. else.

    That's a short feedback so far after a short time. There may be more later on.

    Best regards,
    Spacemarine
     
  14. tyrsis Junior Engineer

    Messages:
    862
    FastResourceLock is pretty simple to use. You either FastResourceLock.AcquireExclusive(); for something similar to lock(), and FastResourceLock.AcquireShared(); for something similar to a reader/writer lock. You just have to remember to release the lock, unless you use FastResourceLock.AcquireExclusiveUsing() which you can use like a lock(), something like:

    FastResourceLock m_lock = new FastResourceLock();

    // locked
    using(m_lock.AcquireExclusiveUsing())
    {
    // ... do stuff
    }
    // lock released
     
    Last edited by a moderator: Nov 7, 2014
  15. Malware Master Engineer

    Messages:
    9,831
    Any chance to add whatever is necessary to create custom enumerators i.e. yielders to the whitelist? I love them. Currently it's complaining about System.Environment, for example.

    Code:
    public IEnumerable<MyCoolThing> GetCoolThings() {
        foreach (var item in this.MyPrimaryCoolThings())
            yield return item;
        foreach (var item in this.MySecondaryCoolThings())
            yield return item;
    }
    
     
    Last edited by a moderator: Nov 7, 2014
  16. eobando Trainee Engineer

    Messages:
    96
    Thanks for the note Tyrsis!
     
  17. Ravenal Apprentice Engineer

    Messages:
    362
    +1 I second this. I had to replace my entire AI because I couldn't use yield
     
  18. jacob88 Trainee Engineer

    Messages:
    4
    Well in regards to the mod API, I wouldn't mind access to an easy to use method of creating clientside hud markers
    e.g. something like...
    Code:
    MyAPIGateway.Utilities.CreateMarker("Marker Text", X, Y, Z)
    
    Unless of course I'm blind and have missed a method of doing this already lol ;)
     
  19. midspace Senior Engineer

    Messages:
    2,224
    And an icon.
    What i posted in the CTG;

    I understand that KeenSWH are to be working on creating Missions in the near future (if not already).

    Would it be possible to introduce Waypoint markers that can be implemented through the API?
    With a filter of which players can see the waypoint, and the range of visibility.
    With custom or at least a selection of icons, and applicable text colors?

    Suggested waypoint icons:
    Mine (ore) here (the existing ore icon as defined in Textures/HUD/HudAtlas0.dds)
    Attack here.
    Enemy here.
    Friend here.
    Unknown here.
    Death here.
    Start here.
    Move here.
    Stop here.
    Hide here.
    Weapons/ammunition stockpile here.
     
  20. midspace Senior Engineer

    Messages:
    2,224
    Also, of interest to be added to the APIs;
    Faction management. (Create, modify, delete. Add player/npc, promote/demote player/npc, remove).
    Are we even able to add npc's to factions?

    Play sound clips.

    A dedicated API that returns the Entity that the Controller is targeting (and is currently visible. A fixed range?)
    (The Ctrl+E is very accurate at determining which ship is targeted for export. Also the Ctrl+X is good at picking asteroids.)
     
  21. midspace Senior Engineer

    Messages:
    2,224
    Need a method either on IMyCubeGrid or IMyEntity, that fetches all the rotor and piston linked grids.
     
  22. midspace Senior Engineer

    Messages:
    2,224
    The struct SerializableVector3 has an:
    Code:
    public static implicit operator SerializableVector3(Vector3 v)
    {
      return new SerializableVector3(v.X, v.Y, v.Z);
    }
    
    Also require a Double operator:
    Code:
    public static implicit operator SerializableVector3([B]Vector3D [/B]v)
    {
      return new SerializableVector3((float)v.X, (float)v.Y, (float)v.Z);
    }
    
    Unless all the Serializable structs are moving up to Double in the future?
    I'm guessing that idea is causing some headaches at the moment.
     
  23. soat7ch Junior Engineer

    Messages:
    605
    I'd love to have some sort of list of all (sub)typeid's and what they are connected to
     
  24. joeblack616 Apprentice Engineer

    Messages:
    225
    Hi, I will clarify about doubles, but I think that everything should be in doubles in future
     
  25. midspace Senior Engineer

    Messages:
    2,224
    Do we have access to reading the EnvironmentDefinition?
    Specifically I'm interested in reading SunDirection, and SunIntensity.
     
  26. jacob88 Trainee Engineer

    Messages:
    4
    Isn't the sun just part of the skybox?
    or are you talking about lighting?
     
  27. Ravenal Apprentice Engineer

    Messages:
    362
    No the sun it's own entity of the sky box.
     
  28. soat7ch Junior Engineer

    Messages:
    605
    Code:
      <SunDirection x="0.339467347" y="0.709795356" z="-0.617213368" />
      <SunIntensity>1.456</SunIntensity>
      <SunSizeMultiplier>200</SunSizeMultiplier>
    
    Just a few examples of what can be found in Environments.sbc

    Either that or i misunderstood your question.
     
  29. Eikester Apprentice Engineer

    Messages:
    423
    those are predefined values, i guess he/she wants to alter these values at runtime via code
     
  30. Ravenal Apprentice Engineer

    Messages:
    362
    Yes he wants to be able to read the values, not sure about the writing, but that is what I think.
     
Thread Status:
Not open for further replies.
This last post in this thread was made more than 31 days old.