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

    Messages:
    271
    Well I think, BroadcastedBogeys/ScanResults/DetectedAntennas/IFFSignals or whatever they might be, could be a completely distinct struct of semi-reliable information, without any clues to the gamepieces they represent, since it is the same like visual: you only see antenna name, it's "stance towards you", distance and direction/position. Adding possibility to actually access that grid from an item in this list, if you have that access, could be a separate step, and indeed, that would need the grid security. Basicly what I meant.

    Even if complete grid access needs security in mind, since you basicly access the gameobjects in that case, sending data messages, or detecting antennas would not allow programmatical access, and still solve creation of more complex, agent based systems; it would allow some basic ai to interact, and many other things.

    Thx for adding.
     
  2. mexmer Senior Engineer

    Messages:
    1,977
    antena internally has method to retrieve list of broadcasters (other antenas), that can be used as base.

    similar as what have been done to ore detector (where list is copied from voxel storage map).
    well, i will think about implementation details later ... no need to further discuss this on forums.
     
  3. Dawnkeeper Apprentice Engineer

    Messages:
    260
    I haven't checked in a while: Was a way to get the position of other grids added to the programmable block?
     
  4. d4rky1989 Apprentice Engineer

    Messages:
    332
    Sorry, but I really don't understand what you are tying to ask for.
    How would you add a grid to a programmable block?
     
    Last edited: Jun 15, 2015
  5. Dawnkeeper Apprentice Engineer

    Messages:
    260
    I don't want to add a grid to the block. I just want to get the info where other grids are and how big they are. For collision detection for a drone.
     
  6. d4rky1989 Apprentice Engineer

    Messages:
    332
    I guess the only chance you have is to use a sensor.
    Some entities you can cast to an object of a type accessible by ingame scripts.
    Here is an example (sensor is set to detect lage ships):

    Code:
    void Main(string argument)
    {
        var sensor = GridTerminalSystem.GetBlockWithName("Sensor") as IMySensorBlock;
        if (sensor == null) {
            Echo ("Sensor not found");
            return;
        }
        var ent = sensor.LastDetectedEntity;
    
        if (ent == null) {
            Echo ("Nothing detected");
            return;
        }
        Echo (ent.GetType ().ToString ());
        var cg = ent as IMyCubeGrid;
        Echo ("GridSize: " + cg.GridSize);
        Echo ("MinCoords: " + cg.Min);
        Echo ("MaxCoords: " + cg.Max);
        var slimBlock = cg.GetCubeBlock (new Vector3I ());
        Echo (slimBlock.FatBlock.GetType().Name);
        Echo ("Block Damage: " + slimBlock.CurrentDamage);
    }
    Using GridToWorld, Min and Max you should be able to calculate the bounding box of the detected grid in the world
     
    Last edited: Jun 16, 2015
  7. Malware Master Engineer

    Messages:
    9,862
    Message removed since the message being responded to was removed.
     
    Last edited: Jun 16, 2015
  8. Newton Trainee Engineer

    Messages:
    79
    I would like to suggest adding projector block to the list.
    It would be very useful to have X Y and Z dimensions of the active projection's bounding box.
     
  9. mexmer Senior Engineer

    Messages:
    1,977
    i'm not exactly sure what you mean.
    all settings from projector are available (except bp name i think).

    but if you mean bounding for projected grid ... might be possible to add "projectedgrid.Min, and projectedgrid.Max" like Min/Max for cubegrid. which defines box around grid. I don't think, it will be possible to add more than that.

    if this is what you mean, i will add it to list
     
  10. Newton Trainee Engineer

    Messages:
    79
    What I meant is the height, width and depth of the smallest cuboid that the projected blueprint would fit into.
    It would be very useful for automated factories as they would be able to determine welder array positions that are needed for welding the projected ship.
     
  11. d4rky1989 Apprentice Engineer

    Messages:
    332
    Found a typo for the blink length property of the interior light:
    currently its named "Blink Lenght" should be "Blink Length"
     
  12. Bleuhazenfurfle Apprentice Engineer

    Messages:
    284
    Ahhh, this is the thread mexmer was referring to, I presume... somehow slipped off my list of tabs while I was working through the forum catching up.

    +1

    also +1

    I'd like to say, I'd rather ONLY have the grid coords on the blocks, not world coords. Most blocks on a grid have no reason to know where they are in world coords. That information should only be provided by blocks that have some sense of what's around them, such as Antenna's, Sensor's, turret's even. So in order to have some idea where you are in world coordinates, you need some block that has a world view, and if for some weird reason you then want to know where a specific block is in world coords, you can figure that out yourself.

    For starters, all the antenna needs to offer for now is a structure with the grid's name/id, current position and velocity data, and other basic information such as we might be able to observe from afar. All of which can be trivially made available through a fully sanitized interface. Though I would like that interface to track the state of the object in question, and for its parameters to be monitorable properties, not just bare values (eg. attach a "let me know if this enemy vessel's distance drops below 1000m"). But in the short term, giving them a something.Get() form would probably be a safe starting point.

    Next, we NEED some inter-grid communication between grids, that doesn't require directly accessing the relevant PB. I've suggested elsewhere, an Action list on the Info pane (and mirrored on the GTS) of a grids Control Panel, and would be reachable from this same interface.

    Personally, I think Actions should themselves have an optional "when finished" Action (MOST Actions would leave it empty, and when not, would likely fire it off immediately). A standard Action list could readily be represented by a chain of such actions, though I think that unwise. Better, it would be used for acknowledgement of actions that will take time (such as auto-pilot directives), and when used in an Action list, processing of the list would typically wait for the response (which means it needs to be reliable - and/or, the block handling the Action could respond with a timeout where one makes sense). Another trivial example, would be a Wait Action (perhaps on Timer blocks), that simply interprets its argument as a period of time, and invokes the attached Action after that time. Would be an interesting alternative to many ideas like adding times to each action in a Timer blocks Actions list. You could either insert its own Wait actions between other actions to introduce delays, or have it run Wait actions with those other actions are the completion Action. (A flag to wait or not, per Action, could work well.) But that's a topic for further discussion...

    I do believe all Actions need to carry a return address, though, so the receiver can apply some custom access controls.

    How do Actions and the existing GTS.Blocks deal with it now? This seems to me to be an issue that NEEDS to be dealt with, because it's standing in the way of a hell of a lot.

    Sounds like I'm certainly not the only one...


    One thing I haven't seen anyone else talking about, is having the 'T' command be a configurable Action on any console or inventory target. Blocks that currently use 'T', would have it pre-configured. Blocks that don't, would leave it blank. As a simple example, a Door would have its 'T' Action linked to OpenClose-Toggle, but you could change it to trigger a Timer block or PB with airlock logic. No more ugly button panels crammed around your doors, just open them like you usually would. (And if you want to force a door to open or close without the 'T' action being intercepted, just hit 'K' and operate it directly from the Control Panel instead.)
     
  13. Newton Trainee Engineer

    Messages:
    79
    Also, since the timer's "trigger now" action is a well-known workaround for program looping, it seems that it would be appropriate to add a Loop() method to the programmable block class (or the program class) that would schedule the program to be run next game tick.
    This method could have an uint parameter to specify the amount of ticks to skip between each run.
     
    Last edited: Jun 17, 2015
  14. Bleuhazenfurfle Apprentice Engineer

    Messages:
    284
    +1e10 :p

    Though there is a gameplay aspect to using the timer... A simple one-shot action can use a PB. A more complex running program, you add an extra block to get the extra functionality. I don't have much against that, really...

    However the Timer block is seriously under-capable to occupy so much space on the grid. I'd like to see it replaced with a more capable sequencer functionality that can do simple programs itself, with sequences of Actions, delays, simple decisions and tests... and have outlined what I'd like to see, personally, in other places, but... *shrugs*

    What could be interesting, is using the Timer block in an enhancement module fashion, like Refineries and their modules, where when it's placed right behind the PB (maybe if you stick it directly onto the back of the PB, rather than placing it down like a normal block, it takes on a slightly different "attached" form), the PB gets a Timer object injected into its namespace that lets you create and manage concurrent timers which call back into your PB script, replacing the chunks of code any reasonably complex PB will invariably have to fudge having multiple timers, loops, and all the rest. I think THAT would be mighty useful!

    And as an aside... alternatively, support for events remove most of the need for a timer anyhow. Timers are usually associated in such cases with polling, which is both evil, and generally unneccesary when you have events.
     
  15. Wicorel Senior Engineer

    Messages:
    1,262
    @mexmer

    We need access to the info in IMyBatteryBlock detailedinfo an a language-independent manner (floats)

    DetailedInfo:
    Type: Battery
    Max Output: 4.00 MW
    Max Required Input: 4.00 MW
    Max Stored Power: 1.00 MWh
    Current Input: 0 W
    Current Output: 0 W
    Stored power: 0 Wh
    Fully depleted in: 0 sec
     
  16. mexmer Senior Engineer

    Messages:
    1,977
    IMyBattery exposes following properties
    CurrentStoredPower
    HasCapacityRemaining
    MaxStoredPower
    IMyBattery also implements IMyPowerProducer interface, with following properties
    CurrentPowerOutput
    DefinedPowerOutput
    MaxPowerOutput
    ProductionEnabled

    i don't thing there is more info required
    IMyPowerProducer was implemented one month ago, or maybe few weeks more.
     
  17. Wicorel Senior Engineer

    Messages:
    1,262
    Ah, excellent.. These things being in multiple places gets confusing (documentation for properties is one place and the actions have to b checked..)
     
  18. mexmer Senior Engineer

    Messages:
    1,977
    IMyPowerProducer and IMyBattery is in documentation

    as for actions ... atm. we don't have access to documentation source, so only directly exposed interface Properties can be documented (using summary), terminalblock actions (IMyTerminalBlock.GetActions) and properties (IMyTerminalBlock.GetProperties) are dynamically added by adding control to block (for example slider, or on/off button), therefore their addition to documentation cannot be easilly automated.

    Still evaluation code for IMyTerminalBlock is quite simple, and with addition of boolean properties (from on/off buttons and checkboxes), they are quite easy to use.
     
  19. Wicorel Senior Engineer

    Messages:
    1,262
    Properties and Actions are not localized so they are not language dependent... right?

    Can we ask for getting 'locale' so scripts can try to localize their messages to the user?

    Also, can we get access to the localized texts? (I haven't' looked at the source, but localized text is usually handled through a stringID system of some sort).
     
  20. Wicorel Senior Engineer

    Messages:
    1,262
    I noticed that their is no 'Input Power' available. This is in the detailed info for batteries. I was using this to discount the power usage in charging batteries as the battery script was in control of that..

    But it would be nice to have access to the input power for all the blocks; not just battery. Making a IMyPowerConsumer seems overkill as most blocks use power.. Can we request getting.. CurrentPowerUsage and MaxPowerUsage added to.. iMyFunctionalBlock.
     
  21. Malware Master Engineer

    Messages:
    9,862
    When making these requests, please keep in mind that the programmable block must make sense within the game universe. It should never have access to anything that a real computer aboard a real ship wouldn't have access to. @mexmer, shouldn't this be a statement on the front page?
     
  22. mexmer Senior Engineer

    Messages:
    1,977
    As for power consumption.
    I've redone that code 3 times already (currently it's on suspension), it's not easy to add, because power grid is entirely different namespace, that is hard to propagate into programable block interface. Also you need to take into account, that not only blocks are "powerconsumers", also your toon, and powerconsumer is different for cockpit type blocks (which can works as recharge station for suit), and there are some blocks lacking power (like landing gear, or connector), yet they won't work without power. simply put, unlike powerproducer, poweconsumer is quite complex thing. Not that powerproducer is simple, but there is limited number of blocks with this interface, and interface is used in straightforward way.

    Atm. only way to get designated maximum block power consumption is trough object builder definitions - but access to object builder might be removed from PB again, so i would not recommend using them in long term.
     
  23. mexmer Senior Engineer

    Messages:
    1,977
    not sure, what you mean that should be put on front page.

    requests that are unrealistic, or requests for api that doesn't exists ingame (either in modapi, or at mywhateverblock definition level), will not be added anyway ;o)
     
  24. Malware Master Engineer

    Messages:
    9,862
    In the initial post, I mean :) Because then people would know beforehand if their request would be rejected outright, before wasting time posting :)
     
  25. mexmer Senior Engineer

    Messages:
    1,977
    nah, you never know, what people might have in mind. so it's better when they post it, then we can discuss what's possible, and what doesn't make sense.
    statement like that in first post, might just scare people :D
     
    • Like Like x 2
  26. Newton Trainee Engineer

    Messages:
    79
    Is the solar panel output available as its property? Where can I find an up to date list of all available properties that interfaces support?
     
  27. mexmer Senior Engineer

    Messages:
    1,977
    from documenation, that is stored in game installation folder

    IMySolarPanel Interface

    Namespace: Sandbox.ModAPI.Ingame
    Assembly: Sandbox.Common (in Sandbox.Common.dll) Version: 1.0.0.0
    Syntax
    C#
    public interface IMySolarPanel : IMyTerminalBlock,
    IMyCubeBlock, IMyEntity, IMyPowerProducer
     
    Last edited: Jul 1, 2015
    • Like Like x 1
  28. Newton Trainee Engineer

    Messages:
    79
    I appreciate the amount of effort you've put in explaining this (seriously, you even took screenshots), but I was trying to point out that solar panel api has no property for current and max output. This requires me to parse the detailedInfo, which is kind of bothersome.
    I was hoping that I was looking in a wrong place since I know that help file.

    EDIT: Duh, it's an IMyPowerProducer which has those methods. Sorry!
    EDIT2 : another thing - is there a way to check thruster's max thrust? Or is it missing from the API? I could use that functionality.
     
  29. mexmer Senior Engineer

    Messages:
    1,977
    i don't think, there is property for maxthrust.
    considering, how thruster grid works, it would not be that simply to get it anyway. value itself is capped depending on grid power suply, and also other factors ... you can look into sourcecode, value is not static.
     
  30. Newton Trainee Engineer

    Messages:
    79
    Well, that's the more reason for a getter, but I "get" it ;). Thanks for help though.
     
Thread Status:
Not open for further replies.
This last post in this thread was made more than 31 days old.