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.

[Suggestion] block.CustomNameWithFaction, myGrid vs connected grid, and cockpit.Occupied

Discussion in 'Programming Questions and Suggestions' started by CyberVic, Jan 7, 2015.

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

    Messages:
    106
    I've written hundreds of lines of code at this point for doing all kinds of various tasks on ships. I'm loving the new in game scripting but there's a few things missing that I think need to be there.

    Firstly, the block.CustomNameWithFaction returns nothing.

    Second, we need a way to identify if the block is part of the grid that the program is executing from or another connected grid (i.e. through a connector).

    Thirst, I want to be able to determine through a IMyCockpit block to be able to determine if it's occupied by a player. This is useful for an auto-dampeners script.


    Last, but certainly not least. Thank you KSH.

    It's been over a decade or more since I wrote code for fun, for me, for a little project for myself. Not for my wife's business. Not for a family member. Not for my job. But for me. I honestly can't remember the last time I did that.

    Thank you. Words cannot describe how much fun this patch has been for me.

    Here are my scripts (updating them as I update the scripts in VS 2012 / in game)
    http://shadecrest.com/site/threads/6884/
     
    Last edited by a moderator: Jan 7, 2015
  2. Textor Junior Engineer

    Messages:
    775
    We've been working on this in another thread. Basically, we determined that

    BlockType.CubeGrid.ToString() returns a consistently formatted string:

    Grid_<D|S>_<Large|Small>_<IDNum> {<bignumber>}

    Where <BigNumber> may or may not be a hash of that grid.

    At the least, you can probably parse this string to compare both size and IDNum of the two grids.

    Er. hm. Uh... How dare you, sir? It is common knowledge among Space Engineers that this update was completely and totally useless and should have been dumped in the trash in favor of optimization. I mean, C# is so hard and stuff. Who wants to learn things!?

    Seriously, though, I agree. Ever since they announced they were going to add this block (and use C# to boot!) I've been very excited, and the reception I've seen from the programming section of the game (including people who actually want to try learning C#!) has been generally positive, with the exception of the typical, "Why did you add X to the game when you could have spent that time optimizing it and/or fixing Y instead!?" I don't get to program in my typical job on a regular basis, so this gives me an awesome excuse to do more programming without having to make a choice between Space Engineers or Visual Studio for my free time.
     
    Last edited by a moderator: Jan 7, 2015
  3. CyberVic Apprentice Engineer

    Messages:
    106
    Thanks for the tip on the gridId. I definitely could leverage that.

    Still would love a cockpit occupied property though and for CustomNameWithFaction to return valid data.
     
    Last edited by a moderator: Jan 8, 2015
  4. szkuwa Trainee Engineer

    Messages:
    7
    Code:
    CustomNameWithFaction actually returns something on IMyRadioAntenna, its just not valid (at least name suggests that it should have other data)
    Code:
    [CODE]antenna.CustomNameWithFaction == <ship name from info tab> + " - " + antenna.CustomName;
    I use it to select correct Antenna on the grid and then get said antenna CubeGrid

    For example I have Ship1 and Ship2 now:
    - iterate over all IMyRadioAntenna and get their names (antennas[0] = "Ship1 - Antenna", antennas[1] = "Ship2 - Antenna")
    - now I can select all blocks on Ship1 using snippet from http://forums.keenswh.com/post/show_single_post?pid=1285784381&postcount=3
    Code:
    var blocks=GetBlocksInTheSameGrid(antennas[0]);
    This will probably be fixed soon but I hope that IMyRadioAntenna will get a field named CustomNameWithShipName or something similar[/CODE]
     
  5. Phoera Senior Engineer

    Messages:
    1,713
    i dont the reasons to fix method in my snippet.
    it dont broke anything.

    i know much more things which must be fixed.
     
  6. szkuwa Trainee Engineer

    Messages:
    7
    It's not your snippet
    I'm just using it as an example here
     
  7. Phoera Senior Engineer

    Messages:
    1,713
    i say method that i used, not just one realization.
     
Thread Status:
This last post in this thread was made more than 31 days old.