Cod Batery

Você também pode gostar

Fazer download em txt, pdf ou txt
Fazer download em txt, pdf ou txt
Você está na página 1de 1

//Este script nos permite mostrar por LCD, nivel de carga de la suma de todas las

baterias de la red
//El script no da formato al texto, es necesario hacerlo manualmente desde el panel
de control del LCD

//Como funciona
//Solo tienes que cambiar la siguiente linea y poner el nombre del LCD de tu nave o
estacion (entre comillas)

const string lcdName = "lcd";

int _lastindex=-1;
IMyTextPanel lcd;

void Main(string arg)


{
lcd=GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel;
var batteries = new List<IMyTextPanel>();
GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(batteries, b=>b.CubeGrid ==
Me.CubeGrid);

if (lcd == null) Echo ("No se ha encontrado LCD' + lcdName + ".\n\ncomprueba


el nombre.");
if (lcd == null) return;

float curPower =0.Of;


float maxPower =0.Of;

for(int i=0; i<batteries.Count; i++){


var b = batteries[i] as IMyBatteryBlock;
curPower += b.CurrentStoredPower;
maxPower += b.MaxStoredPower;
}
if(lcd != null) Echo ("Script en ejecucion");

int index = (int)(20.Of * curPower / maxPower);


if(index > 20 || index < 0)
return; //error
if(index == _lastIndex)
return;

//La variable display text almacena un numero entre 000 y 100


var displayText =*\n "+(string.Format('{0}",(index'5).ToString('D3')));

lcd.ShowTextureOnScreen();
lcd.WritePublicText(displayText,false);
lcd.ShowPublicTextOnScreen();

Você também pode gostar