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.

Merge Block

Discussion in 'Programming Questions and Suggestions' started by Cagatay, Jan 3, 2015.

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

    Messages:
    70
    Hello all,
    I wanted to know if there is a way to check if a merge block is in connected state.
    Like if mergestate = connected {} else {} (to explain what i have in my mind to produce)
     
  2. Locko1997 Trainee Engineer

    Messages:
    17
    I cant find anything on the mod api
     
  3. Cagatay Trainee Engineer

    Messages:
    70
    Thanks for your answer, it would be so good to have it!

    Do you know any workarounds for this?

    Also is sensor detection detectable?

    Edit: Nevermind the question about the sensors :p

    Edit2: Or mind it. Maybe useful to someone else in someway or to me in future.
    Instead of using 2 different sensor to detect small ship/player and to run different scripts in different computers(programmable blocks), it could be like this in 1 code
    if(detectedsmallship){}
    if (detectedplayer){}
     
    Last edited by a moderator: Jan 3, 2015
  4. Cuber Apprentice Engineer

    Messages:
    262
    The only thing I see in the API that would be useful to you is the BeforeMerg eof the IMyShipMergeBlock interface.
    It gets called juuuust before the merge block's indicator color changes to green.
    Example usage:
    Code:
    void Main()
    {
      IMyShipMergeBlock block = GridTerminalSystem.GetBlockWithName("Merge Block") as IMyShipMergeBlock;
      block.BeforeMerge -= BeforeMergeHandler; // removes the event handler in case it already existes - no exception is thrown if it doesn't
      block.BeforeMerge += BeforeMergeHandler;
    }
    void BeforeMergeHandler()
    {
      // This method will be called when the block merges!
    }
    
    However, from what I can tell, disabling the merge block stops the event from being called again meaning you'll need to add the event handler after you re-enable the block. Or something.
     
  5. Cagatay Trainee Engineer

    Messages:
    70
    Thank you for your response and the example, it will help me greatly if it works as intended!

    I'll now test how it works.
     
Thread Status:
This last post in this thread was made more than 31 days old.