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.

[Guide] Programmable Block - DetailedInfo Output

Discussion in 'Programming Guides and Tools' started by Textor, Jan 6, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Textor Junior Engineer

    Messages:
    775
    This is a reference to each block type's DetailedInfo output. <> indicates a variable is expected here, the type is defined inside the brackets. This is the output copied exactly-- lack of proper spacing is because this is how the game outputs the information. Capitalization is also the same. [No Output] means that the game does not output any information for this block.
    Block DetailedInfo String Output
    (All) Cargo Container [No Output]
    (All) Reactors Type: Reactor\nMax Output: <float> MW\nCurrent Output: <float> MW
    (Both) Gravity Generator Type: Gravity Generator\nMax Required Input: <float> kW\nCurrent Input: <float> kW
    Advanced Rotor Current angle: <int>°
    Antenna Type: Antenna\nCurrent Input: <float> kW
    Artificial Mass Type: Artificial Mass\nCurrent Mass: <int> kg\nRequired Input: <float> kW\nCurrent Input: <float> kW
    Assembler Type: Assembler\nMax Required Input: <float> kW
    Battery Type: Battery\nMax Output: <float> MW\nMax Required Input: <float> MW\nMax Stored Power: <float> MWh\nCurrent Output: <int> W\nStored power: <int> Wh\nFully depleted in <int> sec
    Beacon Type: Beacon\nCurrent Input: <float> kW
    Button Panel [No Output]
    Camera Type: Camera\nMax Required Input: <int> W
    Cockpit [No Output]
    Collector [No Output]
    Connector/Ejector [No Output]
    Control Station [No Output]
    Decoy [No Output]
    Door [No Output]
    Drill [No Output]
    Flight Seat [No Output]
    Gatling Turret/Gun [No Output]
    Grinder [No Output]
    Gyroscope Type
    Landing Gear Type: Landing Gear\nLock State: <Unlocked/Ready To Lock/Locked>
    Medbay [No Output]
    Merge Block [No Output]
    Piston Current position: 0.0m
    Programmable Block [No Output]
    Projector [No Output]
    Refinery Type: Refinery\nMax Required Input: <float> kW
    Refinery Type: Refinery\nMax Required Input: <float> kW
    Remote Control Type: Remote Control\nMax Required Input: <float> kW
    Rocket Launcher/Reloadable Rocket Launcher [No Output]
    Rocket Turret [No Output]
    Rotor [No Output] / Current angle: <float>° / Current angle: <float>° / The current rotor rotation is out of limits, the limits will be enabled when the rotor is within range
    Sensor Type: Sensor\nMax Required Input: <int> W\nCurrent Input: <float> kW
    Solar Panel Type: Solar Panel\nMax Output: <float> kW\nCurrent Output: <float> kW
    Sound Block [No Output]
    Spotlight [No Output]
    Thruster [No Output]
    Timer Block [No Output]
    Warhead [No Output]
    Welder [No Output]
    Wheel Suspension [No Output]
     
    Last edited: Apr 13, 2015
    • Like Like x 3
    • Friendly Friendly x 1
  2. MrStump Trainee Engineer

    Messages:
    52
    Excellent list. As an additional note to batteries: When the battery is discharging, then the final part of the string will say "Fully depleted in". But if you activate the battery's recharge mode, then the string will return "Fully charged in". Using this, you can read a battery to tell if it is currently charging or not but using detailedInfoStringName.Contains("charged") or detailedInfoStringName.Contains("depleted") to return a bool (yes or no).
     
  3. dunka Trainee Engineer

    Messages:
    39
    Nice list! I had grabbed the battery info by naming something it's output hah.

    MrStump glad I am not the only person who found that out! I made a ghetto turn my batteries on when solar power goes away script using that as part of the logic.

    Using Max Stored Power and Stored power was a good way to tell if the battery was full as well.

    Totally did not bash my head into the wall for not noticing that Stored power didn't have a capitalized p!
     
  4. GamesOmatic Trainee Engineer

    Messages:
    70
    Great work

    but Rotor isnt quit right:

    [No Output] | Current angle: &lt;float>° | Current angle: &lt;float>° The current rotor rotation is out of limits, the limits will be enabled when the rotor is within range

    The first is when the rotor is placed and never touched,
    the 2nd is once you set a velocity or change upper/lower limits
    the third one is once you set a velocity or change upper/lower limits and you messed up with the limits
     
    Last edited by a moderator: Jan 6, 2015
  5. Textor Junior Engineer

    Messages:
    775
    Thanks, Updated.
     
  6. GamesOmatic Trainee Engineer

    Messages:
    70
    The same should be true for Advenced Rotor.
    I just realized, i am not sure if its float or int
     
    Last edited by a moderator: Jan 6, 2015
  7. Textor Junior Engineer

    Messages:
    775
    Probably float, honestly. After doing the entire properties list, Keen is very fond of their floats.
     
  8. Darkthought Apprentice Engineer

    Messages:
    140
    So is all the data in DetailedInfo just a string that you have to pull the numbers out of?
     
  9. GamesOmatic Trainee Engineer

    Messages:
    70
    DetailedInfo is that what you see in Control Panel in the rigth bottom Control Panel when you selected an Item

    Yes its a string.
     
    Last edited by a moderator: Jan 6, 2015
  10. Darkthought Apprentice Engineer

    Messages:
    140
    That's... icky. Why don't they give us at least read-only access to the variables in there?
     
  11. GamesOmatic Trainee Engineer

    Messages:
    70
    you got read only acces

    for example:

    Gyroscope
    Interface name: IMyGyro
    Parent: IMyFunctionalBlock
    Fields:
    float GyroPower
    bool GyroOverride
    float Yaw
    float Pitch
    float Roll

    IMyGyro c = GridTerminalSystem.GetBlockWithName("Gyroname") as IMyGyro;
    float gyroyaw = c.Yaw;

    gyroyaw return the Value of Yaw on the Gyroscope
     
    Last edited by a moderator: Jan 6, 2015
  12. Warmace Trainee Engineer

    Messages:
    11
    I'm surprised you can't return the volume of stored items in a container such as a a container or reactor.

    Bullets low? Switch to ignore projectiles, close all hatches. Bullets out, self destruct timer.
     
  13. Textor Junior Engineer

    Messages:
    775
    You can, it's just out-of-scope of this list:

    Code:
    IMyInventoryOwner inventoryowner = blocks[0] as IMyInventoryOwner;
    IMyInventory inventory = inventoryowner.GetInventory(0); /*selects first inventory. Assemblers/Refineries have 2, accessible through using "1" as the index.*/
    List&lt;IMyInventoryItem> items = inventory.GetItems();
    float amount = float.Parse(items[0].Amount.ToString());//access the quantity of the items, convert it to a float value.
    
     
  14. daquicker Trainee Engineer

    Messages:
    3
    Hey, I found this guide rather helpfull so I'll just thank you for making it here.

    Is there any way you know of to get the total consumption of power at any given moment on a grid? It is displayed when you acces a control panel but i don't know how to get it in the programming environment without adding all power consuming items together myself.
     
  15. Shuro Apprentice Engineer

    Messages:
    114
    I wonder if you have to parse text, cant you use something like
    Code:
    float amount = (float) items[0].Amount ;
    
    or

    Code:
    float amount = items[0].Amount.value ;
    
    or something like

    Code:
    float amount = items[0].Amount.getAmount();
    
    . I must say I'm not really in C#, but old java- and php-knowledge.
     
    Last edited by a moderator: Jan 7, 2015
  16. Textor Junior Engineer

    Messages:
    775
    IMyInventoryItem.Amount returns a MyFixedPoint class. Someone attempted to use MyFixedPoint.Raw() but it didn't work correctly. The method to fix this was converting .Amount to string and then parsing the number produced as a float, hence

    float.Parse(item.Amount.ToString());
     
  17. Malware Master Engineer

    Messages:
    9,862
    If I'm not mistaken a MyFixedPoint can be cast directly to a float:

    MyFixedPoint p = (some code which gets a fixed point);
    float v = (float)p;

    There may even be implicit cast, which means you can simply assign a MyFixedPoint directly onto a float.



    Haven't tried this in the PB, but I'm pretty sure that is how it worked in the modding API and this is the same code.
     
  18. CyberVic Apprentice Engineer

    Messages:
    106
    Ooooh thanks for this. I only tested detailed info with a few blocks and always got an empty string. I guess I didn't test enough.
     
  19. CubanCreature Trainee Engineer

    Messages:
    33
    Wait, so can someone give a few examples of using DetailedInfo?

    Never mind. I figured it out. Here is an example of using DetailedInfo to get the current position of a piston named "Piston 1" (not the min or max values) and storing it in a variable named "pistonPos". For anyone else who might have had trouble with this like I did.

    Code:
    IMyPistonBase piston = GridTerminalSystem.GetBlockWithName("Piston 1") as IMyPistonBase; 
    double pistonPos = Convert.ToDouble((piston.DetailedInfo.Remove(0,18)).TrimEnd('m'));
    
     
    Last edited by a moderator: Jan 9, 2015
    • Like Like x 1
  20. Sirhan Blixt Apprentice Engineer

    Messages:
    467
    There are methods for parsing string representations of numeric values into values of the correct type. Each valuetype has an associated Parse or TryParse method. I recommend TryParse because you get a boolean value indicating whether the parse was successful instead of a thrown exception.

    Code:
    string numberText = "123.456";
    float numberValue = 0.0F;    // the F distinguishes this from a double-precision floating-point value, or "double"
    float tempValue;
    
    if (float.TryParse(numberText, out tempValue)) {
      numberValue = tempValue;
    }
    
    EDIT: I should have read the second page before replying. Textor already demonstrated the Parse() method above.

    If you're 100% sure that the string representation of the single-precision floating-point value will always be correct and don't want to deal with the conditional logic, you'd do something like this instead:
    Code:
    string numberText = "123.456";
    float numberValue = float.Parse(numberText);
    
     
    Last edited by a moderator: Jan 9, 2015
  21. CubanCreature Trainee Engineer

    Messages:
    33
    What about when the string has a bunch of characters and a number in it, but you only want the number? I posted above how I was able to trim the string and then convert it to a double, but is there a simpler way of doing that?
     
  22. Sirhan Blixt Apprentice Engineer

    Messages:
    467
    You could either write a method that either gives you a copy of the string with all non-numeric characters stripped out, or that gives you a substring that contains just the part with the number in it ... or you could use a Regex that matches the number within the string and then parse the contents of any match.

    I am not in a position to test Regex functionality right now ... there's been some F.U.D. to the effect that they aren't working in the Programmable Block.
     
  23. TheBarret Trainee Engineer

    Messages:
    17

    You can approach this from two ways, regex or per-char parsing.

    Regex, something like this would match against any float point value.

    Code:
    [ -+]?[0-9]*\.?[0-9]+

    Per char, you can make a for loop that iterates thru each char in the string,
    using String.SubString() or String(index), and then confirming it by the Char.IsNumber().

    Remark:
    Now im pretty sure some servers are in regions that interprete a decimal seperator differently, so to make sure you want to use the right one, reference to the System.Globalization namespace for this. From this instance you can get the right Seperator/Number Format you are using.

    Example:
    Code:
    Instance = New CultureInfo("en-US", False);
    
    - Barret
     
    Last edited by a moderator: Jan 24, 2015
  24. Shabazza Junior Engineer

    Messages:
    689
    A noteworthy thing:
    DetailedInfo ist the exact representation of a blocks info box on the bottom right when it is selected in the control panel of the ship/station.
    The entries are separated with "\n" which is not shown in the tables above. So it's really easy to split the lines at "\n" and then parse the values / units from the separate lines.
    Example info string:
    Code:
    Type: Battery\n
    Max Output: &lt;float> MW\n
    Max Required Input: &lt;float> MW\n
    Max Stored Power: &lt;float> MWh\n
    Current Input: &lt;int> W\n
    Current Output: &lt;int> W\n
    Stored power: &lt;int> Wh\n
    Fully depleted in &lt;int> sec
    
    Also:
    @Textor
    For the Battery there is this part missing in your tables:
    Code:
    Current Input: &lt;int> W
    
     
    Last edited by a moderator: Mar 1, 2015
  25. Shabazza Junior Engineer

    Messages:
    689
    @Textor
    Can you update the list with the laser antennas details? :)
     
  26. ViperMan Junior Engineer

    Messages:
    680
    You are my new friend. Next time we meet, I'm buying you a cookie. Unless you're over 21, in which case I have better options...
     
  27. Textor Junior Engineer

    Messages:
    775
    Yep, I get Friday off, so I'm going to stop being distracted and update a bunch of things in the guides, and post some videos.
     
  28. Cuber Apprentice Engineer

    Messages:
    262
    Is the table absolutely butchered for you as well?
    http://i.imgur.com/PuPCCRB.png
     
  29. plaYer2k Master Engineer

    Messages:
    3,160
    Yes, that is due to the different bb-code being used within the new forum.
     
  30. ViperMan Junior Engineer

    Messages:
    680
    The Projector block does have detailed info - it's rather long, and is specific to the blueprint loaded. Of importance is the inclusion of "Build Progress" which tells you how many blocks are left to be built - could be very useful for automation factories.
     
    Last edited: Apr 12, 2015
Thread Status:
This last post in this thread was made more than 31 days old.