Space Engineers

Space Engineers

Easy Radar Homing Script (Decommisioned)
Lynnuxx 3 Jun, 2016 @ 12:48pm
IMyLandingGear.GetAttachedEntity()
Small example script, originally written to quickly display actions and properties of a block:

List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>(); List<ITerminalAction> actionList = new List<ITerminalAction>(); List<ITerminalProperty> propertyList = new List<ITerminalProperty>(); string echoString = ""; public void Main(string argument) { GridTerminalSystem.GetBlocksOfType<IMyLandingGear>(blocks); if(blocks.Count>0) { echoString = blocks[0].CustomName + "\n"; actionList.Clear(); blocks[0].GetActions(actionList); for(int k=0; k < actionList.Count; k++) echoString += actionList[k].Name + " " +actionList[k].Id+"\n"; propertyList.Clear(); blocks[0].GetProperties(propertyList); for(int k=0; k < propertyList.Count; k++) echoString += propertyList[k].Id+"\n"; var LockedGrid = (blocks[0] as IMyLandingGear).GetAttachedEntity() as IMyCubeGrid; if(LockedGrid == null) echoString += "Nothing there !\n"; else { echoString += LockedGrid.ToString()+"\n"; echoString += LockedGrid.Min.ToString()+"\n"; echoString += LockedGrid.Max.ToString()+"\n"; } } else { echoString = "No block found\n"; } Echo(echoString); }

Uses the first landing gear it finds to display its actions and properties as well as some info about an attached grid. Just execute it once and take a look to the Echo-output.

Beware that GetAttachedEntity() returns - as the naming suggests - an entity. You cannot do much with it ingame, just the GetPosition() method and the WorldMatrix property. Everything else will throw an error when trying to compile the script.
In this script I cast it to IMyCubeGrid. This way
1) all non-CubeGrid will return null = won't be found
2) you can do more stuff with it now like analysing the grid for its blocks.

E.g. lock one of your rockets onto the landing gear and run the script.
Or lock a component like an ammo canister onto the LG, it will be locked but not detected by this script.
Last edited by Lynnuxx; 3 Jun, 2016 @ 12:59pm
< >
Showing 1-4 of 4 comments
Alysius  [developer] 3 Jun, 2016 @ 7:22pm 
This will be handy in the Launch Control Script
Lynnuxx 4 Jun, 2016 @ 1:18am 
This method isn't working for me, too, due to game bugs with the landing gear:-(
Looks I found some limits of the game again.
Lynnuxx 4 Jun, 2016 @ 6:11am 
Originally posted by Alysius:
This will be handy in the Launch Control Script
Oh, not for long. Malware just pointed me to a forum post from a KSH developer:
LastDetectedEntity, GetAttachedEntity and so on will be removed from PB access. Instead, an interface will be added to the sensor block which will return a list of a structure containing data of the objects currently detected.
Alysius  [developer] 4 Jun, 2016 @ 9:02am 
Damn.... but anyway the sensor issue they mentioned is quite long, not sure when they are going to implement.
< >
Showing 1-4 of 4 comments
Per page: 1530 50