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.

Ingame Programming missing API and functions and known issues

Discussion in 'Programming (In-game)' started by mexmer, Apr 23, 2015.

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

    Messages:
    263
    Here is a simple experiment:
    1. Create a new station.
    2. The grid is not visible in your ship list.
    3. Add a terminal block, set the ownership to "me".
    4. The grid becomes visible in the list.
    5. Change the name of the grid.
    6. Remove the terminal block.
    7. The grid disappears from the list.
    8. Add another terminal block, set the ownership to "me".
    9. The grid is available in the list under the previously changed name.

    That means the grid name is assosiated with the grid, not with just terminal blocks.
     
  2. Malware Master Engineer

    Messages:
    9,865
    You are correct, the grid name is indeed stored on the grid object itself.
     
  3. plaYer2k Master Engineer

    Messages:
    3,160
    Well good to know. I always believed that the name was related to one of the superordinate "systems" in place controlling certain aspects like wheels/power etc.
     
  4. Dr. Novikov Apprentice Engineer

    Messages:
    263
    Missing API properties:

    • IMyCubeGrid.Speed

    • IMyCubeGrid.GridMass
    • IMyCubeGrid.AttachedGridsMass
    • IMyCubeGrid.CargoMass

    • IMyCubeGrid.CurrentPowerUsage

    • IMyCubeGrid.MaxReactorPowerOutput
    • IMyCubeGrid.CurrentReactorPowerOutput
    • IMyCubeGrid.MaxBatteryPowerOutput
    • IMyCubeGrid.CurrentBatteryPowerOutput
    • IMyCubeGrid.MaxSolarPowerOutput
    • IMyCubeGrid.CurrentSolarPowerOutput
     
  5. mexmer Senior Engineer

    Messages:
    1,977
    @Dr. Novikov wish, it's that easy.
    unfortunately cubegrid is single grid, if you have multiple grids connected .... you understand what i mean.
    if you have looked trough sourcecode, you should have seen powergrid entity. this entity is attached to all grids, that contribute to it (similar to oxygengrid), when 2 separate grid connects, their powergrids are merged into one, but grid themselves are not merged.

    currently there is not entity representing mutiple connnected grids, probly except GTS, which has some quirks tho' also.

    if you will go by current implementation logic you would need
    grid.getpowergrid - then retrieve values from powergrid.
    why, getpowergrid? because even if you find cube from different (connected) grid, you can check it's grid, if it has same powergrid (it should), so if you do own computation on power, you will not multiply values.
     
    • Like Like x 1
  6. Dr. Novikov Apprentice Engineer

    Messages:
    263
    @mexmer somehow the game displays the info on the GUI. That means they already have written the necessary functions. The game could see which powergrid is the cubegrid connected to, and provide the relevant info via API.
     
  7. mexmer Senior Engineer

    Messages:
    1,977
    HUD has indeed access to powergrid subsytem, thruster grid subsytem, gravity grid subsytem, oxygen grid subsytem (yes, this all have own entity, even gyros have one), but PB doesn't have access to HUD info (unlike mods), for obvious reasons (PB can't relate to hud, it can run without player who made the script, it can even run on empty server).

    currently i don't see any optimal solution for this (i even tried to expose powergrid options once in source to pb, but it needed masive change to terminalblock code, and powergrid code). since there is no proper powerconsumer interface, you can't even traverse trough all terminal blocks, and ask about block current consumption (info parsing is not reliable) - which was also thing, i tried to expose, and after many hours spent on code, that again contained massive changes, i tossed it away.
     
  8. d4rky1989 Apprentice Engineer

    Messages:
    332
    Ingame script issue with nested types. Nested types cannot access private members of the enclosing type although they should be able to do that. This code compiles but throws an exception during execution.
    Code:
    void Main (string argument) {
        var inner = new InnerClass (this);
        inner.InvokeEnclosingTest ();
    }
    
    private void Test () {
        Echo ("Hello World");
    }
    
    class InnerClass {
        private Program enclosingType;
    
        public InnerClass (Program enclosingType) {
            this.enclosingType = enclosingType;
        }
    
        public void InvokeEnclosingTest () {
            enclosingType.Test ();
        }
    
        public void SetStorage () {
            enclosingType.Storage = "This is broken due to the nested type issue.";
        }
    }
    Workaround:
    Code:
    void Main (string argument) {
        var inner = new InnerClass (this);
        inner.SetStorage ();
        Echo (Storage);
    }
    
    public void SetStorage (string data) {
        Storage = data;
    }
    
    public string GetStorage () {
        return Storage;
    }
    
    class InnerClass {
        private Program enclosingType;
    
        public InnerClass (Program enclosingType) {
            this.enclosingType = enclosingType;
        }
    
        public void SetStorage () {
            enclosingType.SetStorage ("Hello World");
        }
    }
     
  9. George Armstrong Custer Trainee Engineer

    Messages:
    52
    I have been trying to use the IsShooting property in the IMyUserControllableGun interface with gatling turrets. I haven't been able to get it to work, even though it seems like it should.

    I see some posts in this thread on reported problems with IsShooting. Is this a known and reported issue?
     
  10. Malware Master Engineer

    Messages:
    9,865
    I have fixed this too - it's in the GitHub queue. The reason this fails is that they strip out all nested classes and make "normal" classes out of them, thus removing the inner-class access.

    Code:
    public void Main()
    {
    }
    
    class MySubClass
    {
    }
    
    becomes
    Code:
    public class Program
    {
    	public void Main()
    	{}
    }
    public class MySubClass
    {
    }
    
    rather than

    Code:
    public class Program
    {
    	public void Main()
    	{}
    
    	public class MyClass
    	{}
    }
    
    It's been a while since I fixed these but if memory serves, this was part of the problems causing the Generics issue as well. Not all of it, but a part of it.
     
    • Like Like x 1
  11. Dr. Novikov Apprentice Engineer

    Messages:
    263
    IMyPowerProducer got removed.
     
    • Like Like x 1
  12. daschapa Trainee Engineer

    Messages:
    5
    ...and with it broke the "Configurable Automatic LCDs" and all other scripts that deals with power production.

    ... Same with IMyBatteryBlock
    guess that this might be somehow related to that "base fuel critical" audio message that repeats every minute. (there's a bug been reported about it).
     
    Last edited: Sep 25, 2015
    • Like Like x 1
  13. entspeak Senior Engineer

    Messages:
    1,744
    Is IMyBatteryBlock gone? Ugh... gonna have to check my battery array control script. Hopefully, some new documentation will be coming shortly with the new ResourceSource and ResourceSink groups.
     
  14. Harven Trainee Engineer

    Messages:
    13
    Hey!
    Is OP still maintaining this list? If so here are some issues I would like to report and some suggestions:

    Issues first.
    IMyShipConnector
    - IsConnected and IsLocked properties are switched, so when a connector is connected to another connector IsConnected is false and IsLocked is true, when it's locked - both values are true.
    - OtherConnector - you can access it even when local connector is not locked (you can list what is inside it but you can't transfer items).

    Now suggestions.
    IMyInventory
    - you can find an item using FindItem method - that works great, but then lets say you want to transfer that item to another inventory. To do that you have to know the item's place (ItemIndex) in the source inventory block, but IMyInventoryItem has only ItemId property which is something different than itemIndex needed by TransferItemFrom and TransferItemTo. So now you have to iterate over all item and check if ItemIds match. My suggestion is to add ItemIndex property to IMyInventoryItem OR change that FindItem returns ItemIndex instead of IMyInventoryItem object. There is also GetItemByID method in IMyInventory which returns IMyInventoryItem - it's useless right now in my opinion, because to know ItemId first you have to know IMyInventoryItem.

    Cheers,
    Harven
     
  15. Malware Master Engineer

    Messages:
    9,865
    IsLocked actually means IsMagneticallyLocked. That pull thing. IsConnected means that the connector is actually connected to another connector i.e. with conveyor support. So it's not actually wrong, just confusing when not thinking in the right context :/ I had to name it that way because IsLocked already existed. IMO it should be called Connect/Disconnect anyway :p

    OtherConnector being accessable without actually being connected... that must be a bug and should be reported as such.
     
  16. poxX Trainee Engineer

    Messages:
    3
    Hello everyone.

    I felt like reporting that getting the ongoing timer rundown information is also missing on IMyTimerBlock s.
    The property TriggerDelay only delivers the set beginning TriggerDelay of the timer, not how much time there is left (until count is 0) or has already passed (from start with set TriggerDelay).

    I've only checked OPs list and did not read the thread. If this issue has already been reported I apologize in advance.

    poxX
     
  17. Burillo Junior Engineer

    Messages:
    648
    did anyone figure out how to check oxygen bottle's fill percentage?
     
  18. StanH Trainee Engineer

    Messages:
    73
    I spent hours today figuring out why the X, Y, Z components of a vector don't read properly. Now I noticed you listed it as a bug.

    There is actually a workaround to that issue, without having to parse strings:

    Code:
    float x = (vector * new Vector3(1, 0, 0)).Length();
    float y = (vector * new Vector3(0, 1, 0)).Length();
    float z = (vector * new Vector3(0, 0, 1)).Length();
    
    The same thing works for Vector3I and Vector3D.
     
  19. plaYer2k Master Engineer

    Messages:
    3,160
    Or you simply use double Vector3D.GetDim(int) or if you dont work with Vector3D you should prefer .Dot over the multiplication and .Length() as that is a tiny bit more performant, or should be at least.
     
  20. StanH Trainee Engineer

    Messages:
    73
    Ah, didn't notice those. Thanks.
     
  21. Arcelf Trainee Engineer

    Messages:
    82
    Hey Ishakaru, I've already PM'd you on here and also friended you on steam, I hope thats ok, I just really need to know how you got this load blue print method to work!

    If anyone else could help also, would be great, thankyou!
     
  22. Arcelf Trainee Engineer

    Messages:
    82

    Ok, I figured out how to do it! For anyone else who wishes to know its:-
    Code:
    void Main(string argument)
    {
     IMyProjector proj1 = (IMyProjector)GridTerminalSystem.GetBlockWithName("Projector"); 
     proj1.LoadBlueprint("C:\\Users\\Bob\\AppData\\Roaming\\SpaceEngineers\\Blueprints\\local\\Ship Name\\bp.sbc");
    }
    Thankyou Ishakaru you made my weekend :)
     
  23. Digi Senior Engineer

    Messages:
    2,393
    I wonder if you can use environment variables in that, try:
    Code:
    proj1.LoadBlueprint("%appdata%\\SpaceEngineers\\Blueprints\\local\\Ship Name\\bp.sbc");
    That would make it work on any machine if it actually works.
     
  24. mexmer Senior Engineer

    Messages:
    1,977
    well, that's neat, but honestly proper would be, if you just do
    LoadBluePrint("whatever BP name_i_want") and it would load from "%appdata%\SpaceEngineers\Blueprints\local\whatever BP name_i_want" folder this change was actually part of one PR if i remember correctly, or might be, it was just on suggestion forums. Anyway point is, that you should not need to know location of BP on your disc, you just create bp, save it under "name", and should be able to load it with "name".
     
    • Agree Agree x 1
  25. plaYer2k Master Engineer

    Messages:
    3,160
    Yeah absolutely. I was rather annoyed by that aswell when i made my 3D holodisplay.

    The LoadBlueprint functions should also not be voids but bools to return whether or not they were able to actually load a blueprint.

    But who are we to discuss these things. Keen has sadly shown that they dont care much about the API or community contributions (which drives the API mostly).

    Maintaining the git again would be a nice gift. Though after months i kinda gave up hope already.

    Edit:
    As for loading environment variables you need
    Code:
    //namespace System.Environment
    public static string GetEnvironmentVariable(string variable)
    
    And i dont know if we have access to it. I simply didnt launch SE for a rather long time due to dem darn FO4.
     
    Last edited: Dec 12, 2015
  26. mexmer Senior Engineer

    Messages:
    1,977
    actually you would not need that, if input accept environment variables and translations is done inside (which can be seen in some api, but i still take it as bad practice, you should not have and not need to access environment variables in sandboxed api)

    as for github contribution to api, i'm still waiting for github update to be on regular basis, until then i don't see much point in doing contribution that needs redo every now and then, when ocassional update comes in.
     
  27. Wrapperup Trainee Engineer

    Messages:
    29
    Problem: You can create a variable using "VRage.ModAPI.IMyEntity" to store "Sensor.LastDetectedEntity" or anything else that returns it, allowing you to keep using it even after it has left the range of the sensor.
     
  28. plaYer2k Master Engineer

    Messages:
    3,160
    Like pointed out in "the other thread", this is a known issue and the devs are very well aware of that.
    I personally refer to it as "C# reference bug/exploit" while they call it "Merge block exploit" iirc. A silly name though, especially as it sounds misleading. Anyhow, it is known.
     
  29. mexmer Senior Engineer

    Messages:
    1,977
    well misleading ... you know how that name originated right? from one post on steamforums with example (not sure if it also included vid, but i think so) - hence merge block
    while what you see is technically true, origin is origin, or should we stop calling trojan horses, trojan horses?
     
  30. DS_Marine Apprentice Engineer

    Messages:
    494
    Hey guys.
    Here seems the right place to ask about a way to know if a grid is being piloted?
    I could try with a sensor, but currently it's bugged and disabled in most servers, and also doesn't account for remote control.
    Basically I want to do a failsafe so if you get disconnected, thrusters dampeners become active, and maybe also trigger autopilot to base.
     
Thread Status:
Not open for further replies.
This last post in this thread was made more than 31 days old.