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

    Messages:
    332
    It is possible. I'll post it as soon as I'm at home
     
  2. plaYer2k Master Engineer

    Messages:
    3,160
    Reading a thrusters Override properties max value results in the max thrust.
     
    • Like Like x 1
  3. d4rky1989 Apprentice Engineer

    Messages:
    332
    Yep. Thats it

    Code:
    //IMyTerminalBlock:
    //public static T GetMaximum<T>(
    //	IMyTerminalBlock block,
    //	string propertyId
    //)
    var thrust = GridTerminalSystem.GetBlockWithName("Thrust");
    var maxThrust = thrust.GetMaximum<float> ("Override");
    
     
  4. Xellon Trainee Engineer

    Messages:
    66
    I'm pretty sure this has suggested somewhere else before, but I can't find it ATM:
    Would it be possible to add an Interface to the Remote Control to give PB's the ability to manipulate Waypoints?
    Since the Coordinates of the Waypoints are stored in the Remote Contol itself, a PB should (theoretically) be able to fiddle with them, right?
    Although this would really help me out in my current Project, I will demand nothing here, since the Devs and the Source-Coders might be occupied with more important Stuff! Just a little Suggestion/Reminder from my side! ;)
     
  5. mexmer Senior Engineer

    Messages:
    1,977
    problem with waypoints and gps in general is, that script (especially when run server side), might not have access to GPS.
    when you set you remote, you set it from your GPS collection, but there is no gps collection specific for PB.
    and since PB script can be used by anyone, whose GPS it will read?
    if you set drone with remote to faction share, another player from faction can reprogram waypoints in remote block, but can only pick waypoints from his GPS collection, not from yours, although you set some already in gps.
    maybe when gps is changed, so you can actually share GPS coordinates, and other players can see your shared GPS coordinates (no i don't mean paste in chat. i mean regular ACL for GPS, like is for blocks), then it will be feasible to add gps manipulation to PB.
     
  6. Xellon Trainee Engineer

    Messages:
    66
    Hm. Wouldn't it be possible to give the Remote Contol something else to work with, rather than a GPS Point from a Player? Like, a Vector3D, or a String that contains a GPS Point in the regular format "GPS:Name:X:Y:Z:"? Those would be saved in the PB and could work for all players! Or is there another limitation I have no knowledge of?
     
  7. mexmer Senior Engineer

    Messages:
    1,977
    i don't think there is any limitation, it's just how remote block was designed.
    i can't tell how much changes it will require in remote controller block to make pb programming of waypoints viable tho'.

    although i can see how it can be used for example for directing drones (in combination with laser antena communication script, even remote movement control)
     
  8. Wicorel Senior Engineer

    Messages:
    1,262
    Now with 1.093, scripts could really use the mass of the ship since it's dynamic.

    The appropriate place for this seems to be IMyShipController.
     
  9. plaYer2k Master Engineer

    Messages:
    3,160
    Well, imo the appropriate place is the IMyCubeGrid as that is the representation of the physical entity that has the idealized mass etc.
    But i already made a PR for that a while ago.
     
  10. Wicorel Senior Engineer

    Messages:
    1,262
    I choose IMyShipController because the mass is displayed to the user when controlling it.. But cubegrid is also a good place..
     
  11. abrtn00101 Trainee Engineer

    Messages:
    59
    @mexmer, could you add the inconsistent application of IsShooting to your list? IMyLargeTurretBase doesn't seem to have it even if it's an IMyUserControllableGun. I recall you mentioning on some other thread that the property is not implemented in IMyLargeTurretBase, but I don't see it on your list and it would be nice to have it so we, say, sound an alert or lock some doors when a turret starts reacting to the presence of the enemy.
     
  12. mexmer Senior Engineer

    Messages:
    1,977
    it's not missing
    IMyLargeMissileTurret inherits from IMyLargeTurretBase and also from IMyUserControllableGun, therefore if you retrieve blocks of type IMyLargeMissileTurret you will have IsShooting available, same goes for IMyLargeGatlingTurret and IMyLargeInteriorTurret

    IMyLargeTurretBase is for turret manipulation (elevation, rotation, target tracking - turret ai), but firing control is under IMyUserControllableGun
     
  13. abrtn00101 Trainee Engineer

    Messages:
    59
    I just got back from in-game. Threw this together:
    Code:
    void Main(string argument)
    {
        IMyLargeGatlingTurret master = GridTerminalSystem.GetBlockWithName("Guide Turret 1") as IMyLargeGatlingTurret;
        IMyUserControllableGun master2 = GridTerminalSystem.GetBlockWithName("Guide Turret 2") as IMyUserControllableGun;
        IMyLargeMissileTurret master3 = GridTerminalSystem.GetBlockWithName("Guide Turret 3") as IMyLargeMissileTurret;
        IMyUserControllableGun master4 = GridTerminalSystem.GetBlockWithName("Guide Turret 4") as IMyUserControllableGun;
        IMyLargeInteriorTurret master5 = GridTerminalSystem.GetBlockWithName("Guide Turret 5") as IMyLargeInteriorTurret;
        IMyUserControllableGun master6 = GridTerminalSystem.GetBlockWithName("Guide Turret 6") as IMyUserControllableGun;
        IMyLargeGatlingTurret slave = GridTerminalSystem.GetBlockWithName("Slave Turret") as IMyLargeGatlingTurret;
    
        if (master.IsShooting||master2.IsShooting||master3.IsShooting||master4.IsShooting||master5.IsShooting||master6.IsShooting) slave.ApplyAction("Shoot_On");
        else slave.ApplyAction("Shoot_Off");
    }
    These are paired: first two are gatlings, next two are missile, last two are interior. None of them triggered the condition. Am I missing something?

    Edit: Using a rocket launcher or fixed gatling works just fine. It's just the blocks that inherit from IMyLargeTurretBase that seem to be having a problem.
     
    Last edited: Aug 12, 2015
  14. mexmer Senior Engineer

    Messages:
    1,977
    if they incorectly reporting value, that's most likely bug, and will need fix, but field IsShooting is present on all weapons.
     
  15. abrtn00101 Trainee Engineer

    Messages:
    59
    I just filed a bug report for it.
     
  16. abrtn00101 Trainee Engineer

    Messages:
    59
    Could we add a method or property to IMyThurst to get the current thrust it's producing? And, similarly, to IMyMotorSuspension to know its current angle of rotation (similar to IMyMotorStator) and well as the current steering angle?
     
  17. Wicorel Senior Engineer

    Messages:
    1,262
    You can get the current thrust of a thruster.

    Code:
    thruster.ThrustOverride
    
    I use this code in my miner to display (for informational purposes) the current thrust and percentage of max.

    It only displays the first thruster in the group

     
  18. plaYer2k Master Engineer

    Messages:
    3,160
    But that only works when using override and not when using the normal non-override controls, or does it?
     
  19. Wicorel Senior Engineer

    Messages:
    1,262
    Yes. You are correct. That's override thrust only
     
  20. abrtn00101 Trainee Engineer

    Messages:
    59
    Getting the current thrust of a thruster, outside of override thrust, would allow you to create ships that use vectored thrust by reading the amount of thrust from the other thrusters, cutting down on the number of thrusters a ship would need overall. Arguably, if Keen applies the PR for accessing keyboard input, you could do the same, but I also have other ideas in mind. For example, with the way mass works now, thrusters can torque a ship around heavy loads. If you have a ship with several arrays of thrusters designed to move heavy loads, losing a certain amount of thrusters on one side can cause the ship to veer to one side. If you know the total amount of thrust each side produces, you can modulate thrust based on your losses on the other side. Or you could create ships with wildly asymmetrical mass distributions.
     
  21. Dr. Novikov Apprentice Engineer

    Messages:
    263
    IMyCubeGrid: really need an in-game API for getting and setting ship's name. I'd like to add statuses (Damaged, Low power, Work finishedm etc) to the names of my ships and see them in my ships list.
     
  22. plaYer2k Master Engineer

    Messages:
    3,160
    The name is set per IMyGridTerminalSystem though and not per IMyCubeGrid. But yes it is indeed needed.

    We also need a method to modify loaded blueprint grids, still. This has been suggested so many months ago though.
    I guess the best method for that might be a IMyModifyableCubeGrid wrapper that takes the methods from the ModAPI IMyCubeGrid to alterate it and exposes it to both the modAPI for all cubegrids aswell as the projected cubegrid from projectors.
     
  23. Dr. Novikov Apprentice Engineer

    Messages:
    263
    Is there currently any way to get/set ship's name by in-game scripts?
     
  24. plaYer2k Master Engineer

    Messages:
    3,160
    Oh no, sorry if it sounded like that. The IMyGridTerminalSystem however is what represents the conjunction of all IMyCubeGrids that are connected. Thus the IMyGridTerminalSystem is the only place that seems to fit the requirement for that function, like any other setting within the other terminal tabs.
     
  25. Dr. Novikov Apprentice Engineer

    Messages:
    263
    Isn't IMyGridTerminalSystem representing the terminal blocks, not the whole ship? A grid without any terminal blocks is still a grid, and it still has a name. IMyCubeGrid has properties like IsStatic. I tried to access it's DisplayName and got an error.
     
  26. plaYer2k Master Engineer

    Messages:
    3,160
    What you refer to there is an IMyTerminalBlock, which is just a single terminal block and thus a block that is accessible within the IMYGridTerminalSystem.
    The IMyGridTerminalSystem is the "system" that you access when pressing k within a cockpit or when accessing a conveyor hatch / button. An IMyGridTerminalSystem thus is the conjunction of all IMyCubeGrids.
     
  27. Wicorel Senior Engineer

    Messages:
    1,262
    A grid without any terminal blocks is just a collection of armor/decoration blocks. It might possibly have a name, but without a cockpit of some kind to access it, the user can't know/set the name..
     
  28. Dr. Novikov Apprentice Engineer

    Messages:
    263
    Well, I need to rename not the conjunction, but separate "parts" of the "conjuncted". Separate ships, not a station with whatever is docked to it.
     
  29. Dr. Novikov Apprentice Engineer

    Messages:
    263
    A user can know the name from the list of his ships.
     
  30. Wicorel Senior Engineer

    Messages:
    1,262
    Not sure what list you're talking about. K menu only shows ships with terminal blocks.
     
Thread Status:
Not open for further replies.
This last post in this thread was made more than 31 days old.