1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

Airtight Hangar Door and Block Groups

Discussion in 'Programming (In-game)' started by Leaping Tortoise, Apr 8, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Leaping Tortoise

    Leaping Tortoise Apprentice Engineer

    Messages:
    212
    Hi all,

    I'm very new to programming so I apologise if this is very simple or has already been discussed. I'm currently trying to write a script for a ship to ship airlock that won't vent my entire compartment into space. I've got the airlock built and it works I'd just like to have a program running in the background that makes sure it's used correctly. I've run into two problems.

    1) I can't seem to find out how to use the Airtight Hangar Door in the programming block ie there doesn't seem to be something like "IMyAirtightHangarDoor."
    2) Is there a way to access a group of blocks? Eg I have 20 lights in a group labeled "Lights." Can I use the programming block to send a command to this group, rather than to each individual light.

    Thanks for any help.
     
  2. plaYer2k

    plaYer2k Master Engineer

    Messages:
    3,160
  3. Xentor

    Xentor Junior Engineer

    Messages:
    869
    Don't they implement IMyDoor? Pretty sure I had my airlock script working with them by casting to IMyDoor.
     
  4. Leaping Tortoise

    Leaping Tortoise Apprentice Engineer

    Messages:
    212
    See I tried doing it as an "IMyDoor." Doors and Airtight Hangars have exactly the same functions just a different graphic so I thought it might be something that they bundled together (kinda like cargo containers). It didn't work for me but maybe I'd done something wrong. I'll have another look at my script tomorrow.

    Thanks for the thread on groups, plaYer2k. The commenting really helps with learning. I'm finding that I have absolutely no clue as to what a given line of code does until I try to use it and see the result (unfortunately the result seems to be "error" a lot but I'll keep trying :D )
     
  5. plaYer2k

    plaYer2k Master Engineer

    Messages:
    3,160
    When you got errors, always make sure to copy-paste your code into a [code]...[/code] tag and give the error message within the PB. There are more than enough people willed to help here so dont hesitate to ask.
     
  6. Leaping Tortoise

    Leaping Tortoise Apprentice Engineer

    Messages:
    212
    Will do. I'm just not at home at the moment :( Thanks for the offer.
     
  7. MisterSwift

    MisterSwift Apprentice Engineer

    Messages:
    367
    Airtight Hangar Door actions:
    • OnOff - Toggle block On/Off
    • OnOff_On - Toggle block On
    • OnOff_Off - Toggle block Off
    • Open - Open/Closed
    • Open_On - Open
    • Open_Off - Closed
    .GetProperties returns zero ITerminalProperty items
    Casting an airtight hangar door as IMyDoor exposes Open property that returns the proper value

    Code:
    void Main() {
       IMyDoor someDoor = GridTerminalSystem.GetBlockWithName("Airtight Hangar Door") as IMyDoor;
       bool isOpen = someDoor.Open;
    
       if (isOpen) {
          someDoor.ApplyAction("Open_Off");
       }
    }
     
    Last edited: Apr 8, 2015
    • Like Like x 1
Thread Status:
This last post in this thread was made more than 31 days old.