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.

Point to the program block which i actually script

Discussion in 'Programming Questions and Suggestions' started by BobbySix, Mar 3, 2017.

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

    Messages:
    32
    Hi everyone,

    Is there anyway to get the actual program block where i script without using indirect method like scanning tag in any user custom field ?

    Or actual main grid at least ?
     
  2. Sinbad Senior Engineer

    Messages:
    2,788
    You want the script to be able to access the PB its running on?
    I think its 'Me' or something like that. I remember seeing it in a thread a few months ago...
     
    • Agree Agree x 2
  3. Wicorel Senior Engineer

    Messages:
    1,240
    Correct.
     
  4. Martin R Wolfe Trainee Engineer

    Messages:
    80
    Yes it is "Me". I use that a lot in the debug part of my scripts by having the PB find the display panel above it to put it's output on.

    Example code:-
    Code:
    IMyTextPanel DefaultDisplay{ get {
        IMyCubeGrid CubeGrid=Me.CubeGrid;     
        Quaternion aQuaternion; 
        List<IMyTextPanel> Displays = new List<IMyTextPanel>();   
        Me.Orientation.GetQuaternion(out aQuaternion);     
        Vector3I TargetLoc= Me.Position+Vector3I.Transform(new Vector3I(0,1,1),aQuaternion);     
        GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(Displays,       
            x=>((x.CubeGrid==CubeGrid)&&(x.Position==TargetLoc)));
        return Displays.Count!=0?Displays[0]:null; 
    }}
    
    
     
  5. BobbySix Trainee Engineer

    Messages:
    32
    Works perfectly, thanks :)
     
Thread Status:
This last post in this thread was made more than 31 days old.