//SCRIPTINPUT (FS) void init() { antenna.Enabled = true; antenna.SetValue("EnableBroadCast", true); if (antenna.TransmitMessage("Init message", MyTransmitTarget.Owned)) { parent.Echo("Com System online"); ComWorking = true; } if (!antennaAlwaysOn) { antenna.SetValue("EnableBroadCast", false); } }
//NO INPUT (FS) public Program() { antenna = GridTerminalSystem.GetBlockWithName(ANTENNA_NAME) as IMyRadioAntenna; if (antenna != null) { output = GridTerminalSystem.GetBlockWithName(OUTPUT_NAME); try { IMyTextPanel textPanel = output as IMyTextPanel; textPanel.WritePublicText(""); outputIsTextPanel = true; } catch (Exception) { outputIsTextPanel = false; } //TODO assign antenna to pb in script (even possible?) isWorking = true; antenna.SetValueFloat("Radius", RANGE); switch (ACCEPT_MESSAGE) { case 0: antenna.IgnoreOtherBroadcast = false; antenna.IgnoreAlliedBroadcast = false; break; case 1: antenna.IgnoreOtherBroadcast = true; antenna.IgnoreAlliedBroadcast = false; break; case 2: antenna.IgnoreOtherBroadcast = true; antenna.IgnoreAlliedBroadcast = true; break; default: antenna.IgnoreOtherBroadcast = true; antenna.IgnoreAlliedBroadcast = false; break; } if (ALWAYS_ON) { antenna.SetValue("EnableBroadCast", true); } else { antenna.SetValue("EnableBroadCast", false); } } else { Echo("Antenna could not be found"); isWorking = false; return; } if (CHAT_MODE) { chathandler = new ChatHandler(this, CHAT_NAME); } if (OWN_NAME == "") { OWN_NAME = Me.CubeGrid.CustomName; } OWN_NAME = OWN_NAME + "/" + Me.EntityId % 10000; comHandler = new ComModule(this, antenna, OWN_NAME, ALWAYS_ON); Me.CustomName = "PB-COM-" + OWN_NAME; Me.CustomData = ""; }
private void FirstTimeSetup(IMyRemoteControl rc) { try { RC1 = rc; myGridTerminal.GetBlocksOfType <IMyOreDetector>(oreDetectors, b => b.CubeGrid == RC1.CubeGrid); myGridTerminal.GetBlocksOfType <IMyCameraBlock>(cameraBlocks, b => b.CubeGrid == RC1.CubeGrid); myGridTerminal.GetBlocksOfType <IMyBatteryBlock>(batteryBlocks, b => b.CubeGrid == RC1.CubeGrid); myGridTerminal.GetBlocksOfType <IMyRadioAntenna>(RadioAntennas, b => b.CubeGrid == RC1.CubeGrid); if (cameraBlocks.Count > 0) { cameraBlock = cameraBlocks[0]; } myGridTerminal.GetBlocksOfType(mySmallMissiles, b => b.CubeGrid == RC1.CubeGrid); myGridTerminal.GetBlocksOfType(mySmallGatlings, b => b.CubeGrid == RC1.CubeGrid); myGridTerminal.GetBlocksOfType(myLargeTurrets, b => b.CubeGrid == RC1.CubeGrid); } catch (Exception e) { print(e.Message); } try { List <IMyTerminalBlock> TEMP_CON = new List <IMyTerminalBlock>(); myGridTerminal.GetBlocksOfType <IMyShipConnector>(TEMP_CON, b => b.CubeGrid == RC1.CubeGrid && b.CustomName.Contains("Ejector") == false); CONNECTOR1 = TEMP_CON[0] as IMyShipConnector; } catch { } try { List <IMyTerminalBlock> TEMP_GYRO = new List <IMyTerminalBlock>(); myGridTerminal.GetBlocksOfType <IMyGyro>(TEMP_GYRO, b => b.CubeGrid == RC1.CubeGrid); GYRO = TEMP_GYRO[0] as IMyGyro; } catch { } //Initialising Dedicated Cargo try { myGridTerminal.GetBlocksOfType <IMyCargoContainer>(Cargo, b => b.CubeGrid == RC1.CubeGrid); } catch { } //Gathers Antennae try { List <IMyTerminalBlock> TEMP = new List <IMyTerminalBlock>(); myGridTerminal.GetBlocksOfType <IMyRadioAntenna>(TEMP, b => b.CubeGrid == RC1.CubeGrid); RADIO = TEMP[0] as IMyRadioAntenna; RADIO.SetValue <long>("PBList", RC1.EntityId); RADIO.EnableBroadcasting = true; RADIO.Enabled = true; } catch { } //GathersControllers try { myGridTerminal.GetBlocksOfType <IMyShipController>(CONTROLLERS, b => b.CubeGrid == RC1.CubeGrid); } catch { } //Gathers Director Turret try { myGridTerminal.GetBlocksOfType <IMyLargeTurretBase>(DIRECTORS, b => b.CubeGrid == RC1.CubeGrid); } catch { } //Gathers Drills try { myGridTerminal.GetBlocksOfType <IMyShipDrill>(SHIP_DRILLS, b => b.CubeGrid == RC1.CubeGrid); } catch { } //Gathers Directional Weaponry try { myGridTerminal.GetBlocksOfType <IMyUserControllableGun>(DIRECTIONAL_FIRE, (block => ( block.GetType().Name == "MySmallMissileLauncher" || block.GetType().Name == "MySmallGatlingGun" || block.GetType().Name == "MySmallMissileLauncherReload" ) && block.CubeGrid == RC1.CubeGrid) ); //Collects the directional weaponry (in a group) } catch { } //Runs Thruster Setup try { CollectAndFire2(new Vector3D(), 0, 0, RC1.GetPosition(), RC1); for (int j = 0; j < CAF2_THRUST.Count; j++) { CAF2_THRUST[j].SetValue <float>("Override", 0.0f); CAF2_THRUST[j].ApplyAction("OnOff_On"); } } catch { } }