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.

Important Ingame API Issues

Discussion in 'Programming (In-game)' started by rexxar, Oct 10, 2017.

  1. rexxar Senior Engineer

    Messages:
    1,530
    Hi everyone! I'm here to fix the PB API as well as ModAPI!

    So, give me your problems! Please do not post feature requests in this thread, as they will be handled in another thread!

    Please describe how the function currently behaves, how it should behave, and attach a script which shows the problem. The easier you make it for me to reproduce the issue, the faster I can get it fixed .:)
     
  2. krypt-lynx Apprentice Engineer

    Messages:
    175
    PB:

    • Program() vs grid creation
    • Mysterious "Too Complex Exception" for PBs (even if it was not started/was turned off)
    • Some actions in Save() method are crashes game (using .TryRun(), for example)
    • another actions in Save() causing script exception (access to .TimeSinceLastRun, for example). Also, if exception was catched can cause game crash.
     
    • Agree Agree x 1
  3. Wicorel Senior Engineer

    Messages:
    1,239
    Last edited: Oct 10, 2017
    • Like Like x 2
    • Agree Agree x 2
  4. Gwindalmir Senior Engineer

    Messages:
    1,003
    Terminal action names are not named in a consistent manner.

    These are the names used in code, with block.ApplyAction("ActionName").

    Some have space, some have PascalCase, some camelCase, others have no capitals at all. Some are mismatched in the same file.

    Some examples:

    Turret:
    "ShootOnce"
    "Shoot"

    MyButtonPanel:
    "AnyoneCanUse"
    "Open Toolbar"

    MyTimer:
    "TriggerDelay"
    "OpenToolbar"

    MyAssembler:
    "slaveMode"

    MyConveyorSorter:
    "DrainAll"
    "candidatesList"

    MyGasGenerator:
    "Refill"
    "Auto-Refill" (notice the hyphen)

    MyMotorStator:
    "Add Top Part"
    "Add Small Top Part"
    "Reverse"
    "BrakingTorque"


    I think some of the above are not actually usable in PB, but the inconsistencies are still noted.
     
    • Agree Agree x 1
    • Informative Informative x 1
  5. Digi Senior Engineer

    Messages:
    2,364
    MyCubeGrid.GetCurrentMass()'s returned value (used by IMyShipController.CalculateShipMass()) is wrongly calculated, it adds pilot's mass to each subgrid's mass and it also doesn't include other seated characters.
     
    • Agree Agree x 2
    • Like Like x 1
  6. krypt-lynx Apprentice Engineer

    Messages:
    175
    • Agree Agree x 1
  7. Malware Master Engineer

    Messages:
    9,405
    IMyThrust should have an override boolean so we can override a thruster to not fire
     
    • Agree Agree x 6
  8. Whiplash141 Junior Engineer

    Messages:
    957
    Here is a fix for Keen's consideration:
    Code:
    Vector3D VectorRejection(Vector3D a, Vector3D b) //reject a on b  
    {
        if (Vector3D.IsZero(b))
            return new Vector3D(0, 0, 0);
    
        return a - a.Dot(b) / b.LengthSquared() * b;
    }
    
    It works for vectors of any length and even checks for zero vector to avoid NaN errors and exceptions
     
  9. qsek Trainee Engineer

    Messages:
    29
    Echo gives out an "Index was out of range" Exception when you try to Echo more than 7999 Characters.
    [​IMG]

    Reproducer:
    Run it a couple of times, scroll down to the end after first run so you see the char count.
    Code:
    public Program() {
    
    
                for (int i = 0; i < 7950; i+=10) 
                { 
                    bla += "1234567890";
                } 
                return;
    
    }
    
    
    string bla = "";
    
    public void Main(string argument) {
    
               
                for (int i = 0; i < 10; i+=10)
                {
                    bla += "1234567890";
    
                    Echo(bla);
                    Echo("COUNT: "+bla.Count());
                }
    }
    Possible Culprit: EchoTextToDetailInfo
    https://github.com/KeenSoftwareHous...e/Entities/Blocks/MyProgrammableBlock.cs#L719
     
    • Like Like x 1
  10. Malware Master Engineer

    Messages:
    9,405
    Correct. You're trying to echo a line that's longer than the maximum buffer size, so the buffer is first cleared and the line updated to be within the maximum size, but the lineLength is never updated to this new length.

    Corrected code:
    Code:
    if (lineLength > MAX_ECHO_LENGTH)
    {
        // If the input line is already longer than the maximum allowed length,
        // we clear the current output and add only allowed portion of the string
        // to the output. Obviously this is unlikely to happen but it could.
        m_echoOutput.Clear();
        line = line.Substring(0, MAX_ECHO_LENGTH);
        lineLength = MAX_ECHO_LENGTH;
    }
    
     
    • Like Like x 1
  11. Hellothere! Apprentice Engineer

    Messages:
    412
    On builds with many subgrids some blocks won't get recognized immediatly when loading a blueprint or world. On some of my scripts I currently have the program initialize with a counter that counts to two and only then activates the setup to avoid this but a fix would be nice.
     
  12. Wicorel Senior Engineer

    Messages:
    1,239
    I put in a bug for this. SE-5452.

    Here is the example world I used in the bug report. The steps to demo the bug are in the world.
    http://steamcommunity.com/sharedfiles/filedetails/?id=1160645160
     
  13. Elfi Wolfe Apprentice Engineer

    Messages:
    497
    everything I have noticed.. has been posted by other people or is in the bug system.
     
  14. w0lf3y Apprentice Engineer

    Messages:
    152
    Rotors use .SafetyLock pistons do not.
    please add a .SafetyLock bool to pistons.


    Has this already been addressed?
    A code I have been working on suddenly started working when I came back to it.
    piston.SafetyLock is now valid and no longer fails compile.
     
    Last edited: Oct 21, 2017
  15. Malware Master Engineer

    Messages:
    9,405
    Wrap GTS per programmable block: Today the GTS instance actually _changes_ during runtime when locking with connectors (and merge blocks obviously). This is not expected from a property and people trying to cache this and send it into their subclasses gets surprised when their classes stop working because the instance is no longer correct.
     
    Last edited: Oct 20, 2017
    • Agree Agree x 4
    • Like Like x 1
  16. posthy Apprentice Engineer

    Messages:
    113
    -Build a grid with two PB
    -Paste any code from the workshop into either PB
    -Select all and copy the code from that PB and paste it to the other
    Each time you repeat this the code gets bigger and bigger, the game adds trailing space to every line.
     
    • Agree Agree x 2
  17. SubVision Trainee Engineer

    Messages:
    11
    Add possibility for thrusters to override less than 1%
     
    • Agree Agree x 3
  18. Hellothere! Apprentice Engineer

    Messages:
    412
    Some issues with projectors I noticed recently:
    1. If you change the blueprint while a programmable block changes the offset of the projection the game will crash.
    2. Using .projectionOffset will only affect the host, but not other players on a server. I'm currently forced to use this code as a workarround:
      Code:
                  public void MoveMarker (IMyProjector projector,Vector3I position)
                  {
                      for (int i = projector.ProjectionOffset.X; i < position.X; i++)
                          projector.ApplyAction("IncreaseX");
                      for (int i = projector.ProjectionOffset.X; i > position.X; i--)
                          projector.ApplyAction("DecreaseX");
                      for (int i = projector.ProjectionOffset.Y; i < position.Y; i++)
                          projector.ApplyAction("IncreaseY");
                      for (int i = projector.ProjectionOffset.Y; i > position.Y; i--)
                          projector.ApplyAction("DecreaseY");
                      for (int i = projector.ProjectionOffset.Z; i < position.Z; i++)
                          projector.ApplyAction("IncreaseZ");
                      for (int i = projector.ProjectionOffset.Z; i > position.Z; i--)
                          projector.ApplyAction("DecreaseZ");
    3. If you use any of the Decrease[axis]/Increase[axis] methods (as above) while or shortly after switching the projector on the projection seems to have a ~50% chance to randomly disappear. Even de- and reactivating the projector won't bring it back in that case. You have to reload the blueprint to fix it.
     
  19. Malware Master Engineer

    Messages:
    9,405
    The status property of an Air Vent reports Pressurized when an airvent is in a pressurizable but not pressurized room. To reproduce just make a sealed box, place a power source, and air vent and a PB, just dump the status of the vent.
     
  20. Sirhamsteralot Trainee Engineer

    Messages:
    28
    Setting a font for LCD's.
     
  21. krypt-lynx Apprentice Engineer

    Messages:
    175
  22. Digi Senior Engineer

    Messages:
    2,364
    The turret's SyncAzimuth()/SyncElevation()/SyncEnableIdleRotation() methods seem really off, why are they needed? Why not sync it automatically like everything else.

    And about the font setter/getter: there should be a proper interface property/method that accepts the font ID or font visual name.
     
  23. Sirhamsteralot Trainee Engineer

    Messages:
    28
    sounds retarded doesnt it? wouldnt it be nice if we could just set it with a nice little enum or something?
     
  24. Malware Master Engineer

    Messages:
    9,405
    Except enums wouldn't take modded fonts into account...
     
  25. rexxar Senior Engineer

    Messages:
    1,530
    Simple, dynamic enums ;)
     
  26. Malware Master Engineer

    Messages:
    9,405
    Then they aren't enums any more :p
     
    • Agree Agree x 1
  27. krypt-lynx Apprentice Engineer

    Messages:
    175
    It will be a little easier if you will allow VRage.Utils.MyUtils and/or VRage.Utils.MyStringHash in ingame scripts. Linked code is a copypasted part of the game.
    --- Automerge ---
    I will really appreciate if somebody will fix crash in Terminal after script recompilation. This thing annoys me more then any API limitation. I mean, there is no any sense in ingame API improvements of you cannot use ingame API.


    It happens is you will insert new version of script into editor, close it, and stay it in termiral on bp's page for a while. Exact thing what a you doing thin debugging your script.
     
  28. rexxar Senior Engineer

    Messages:
    1,530
    You have to call UpdateOffsetAndRotation to update clients after changing the offsets.
     
    • Informative Informative x 1
  29. Hellothere! Apprentice Engineer

    Messages:
    412
    Oh cool, thanks for the tip. Could you maybe add that to the summary of .projectionOffset then? It would probably help avoid other people having the same problem as I did.
     
    • Agree Agree x 1
  30. rexxar Senior Engineer

    Messages:
    1,530
    Got it.


    Won't do. Can't change those without breaking things, so I made proper getter/setter/method for everything. You're welcome.
    ;)

    will look into it
    Got it
    Reasons, probably. I'll see if we can do anything.
     
    • Like Like x 1