Space Engineers

Space Engineers

评价数不足
LCD_ComponentList
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
1.339 KB
2015 年 4 月 12 日 上午 4:59
1 项改动说明 ( 查看 )

订阅以下载
LCD_ComponentList

描述
//this script shows how much components of each type you have stored in your cargo containers
//on your ship/station. (it does not show ores/ingots)
//----------------------------------------------------------------
//use a timer block to run this code frequently;
//replace "lcdName" by the Name of the lcd display to show the cargo overview

void Main()
{
String lcdName = "Put LCD-Display-Name in here"; //Name of the LCD-Display (Normal LCD or Wide LCD)
bool prepareDisplay = true; //Set to false after the first run

//-----------------------------------------------------------------------------------------------------------------

var lcdDisplay = GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel;

if (prepareDisplay) {
lcdDisplay.SetValueFloat("FontSize" , 1.5f);

Color textColor = new Color(230, 230, 230);
lcdDisplay.SetValue("FontColor", textColor);

Color backColor = new Color(0, 0, 30);
lcdDisplay.SetValue("BackgroundColor", backColor);

lcdDisplay.WritePublicTitle("Borditemliste");

lcdDisplay.ShowPublicTextOnScreen();
}

//-----------------------------------------------------------------------------------------------------------------

//Normal LCD in this config allows 9 (max 10) Items to display
String[] itemTypes = {
"NATO_25x184mm",
"Missile200mm",
"SteelPlate",
"Construction",
"Explosives",
"Display",
"Motor",
"InteriorPlate",
"BulletproofGlass",
"Girder",
"LargeTube",
"SmallTube",
"MetalGrid",
"Scrap",
"Thrust",
"Reactor",
"RadioCommunication",
"GravityGenerator",
"Medical",
"SolarCell",
"PowerCell",
"Detector",
"Computer",
"NATO_5p56x45mm"
};

String[] itemDisplay = {
"Munition:",
"Raketen:",
"Stahlplatten:",
"Herstellungskomponenten:",
"Sprengstoff:",
"Anzeigen:",
"Motoren:",
"Interne Panzerung:",
"Panzerglass:",
"Träger:",
"Stahlrohr Groß:",
"Stahlrohr Klein:",
"Metallgerüst:",
"Metallabfall:",
"Triebwerksteile:",
"Reaktorkomponenten:",
"Kommunikationsteile:",
"Gravitationskomponenten:",
"Medizinischekomponenten:",
"Solarzellen:",
"Energiezellen:",
"Sensorkomponenten",
"Computer:",
"Magazine:"
};

var cargoContainers = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocksOfType<IMyCargoContainer>(cargoContainers);

if(cargoContainers.Count == 0)
{
return;
}

int[] itemListCount = new int[itemTypes.Length];

for (int i = 0; i < cargoContainers.Count; i++)
{
IMyCargoContainer currentCargoBlock = (IMyCargoContainer)cargoContainers;

List<IMyInventoryItem> items = new List<IMyInventoryItem>();
items = currentCargoBlock.GetInventory(0).GetItems();

for (int x = 0; x < items.Count; x++) {
for (int k = 0; k < itemTypes.Length; k++) {

if (items[x].Content.SubtypeName == itemTypes[k]) {
itemListCount[k] += (int)items[x].Amount;
}
}
}
}

String lcdText = "Cargoübersicht:" + "\n------------------------\n";

for (int l = 0; l < itemDisplay.Length; l++) {
if (itemListCount[l] > 0) {
lcdText += itemDisplay[l] + " " + itemListCount[l].ToString() + "\n"; } } lcdDisplay.WritePublicText(lcdText, false);}
4 条留言
jirok 2015 年 4 月 13 日 上午 11:53 
PulsatorPeters dice, crear pantalla LCD - para crear el nombre de la pantalla LCD, 'LCD' o 'widescreen LCD', bajo {String lcdName = "Put LCD-Display-Name in here";} apuntarse.

Allí se crea una lista de todos los componentes y su número son ubicados en contenedores de carga y aparece en la pantalla LCD. Desafortunadamente, los minerales y bares, no aparecen.

Un bloque temporizador tiene sentido, para que la pantalla se actualiza regularmente. Quien quiera puede adaptar los textos en itemDisplay, este es el texto que se muestra para los correspondientes componentes (términos alemanes aquí utilizados).

Ich sage, thx ... werd' ich ausprobieren. ;)
PulsatorPeters  [作者] 2015 年 4 月 13 日 上午 6:52 
Ihr erstellt ein LCD-Display und fügt den Namen von dem Display in der ersten Zeile ein
{String lcdName = "Put LCD-Display-Name in here";}

Es wird eine Liste aller Komponenten und deren Anzahl erstellt, die sich in Cargo Containern befinden und im LCD-Display angezeigt. Erze und Barren werden leider nicht aufgelistet.

Ein Timer-Block ist sinnvoll, damit das Display regelmäßig aktualisiert wird. Wer will kann auch die Texte in itemDisplay anpassen, dies ist der Text der für die entsprechenden Komponenten angezeigt wird (habe hier deutsche Begriffe verwendet).
jirok 2015 年 4 月 13 日 上午 3:53 
chema sagt, wie soll ich das installieren? Stell' bitte einige Beispiele rein oder noch besser wäre ein Video.

Ich sage, ein Pic, wie es in Aktion aussieht, wäre auch schon nicht schlecht. ;)
Ares 2015 年 4 月 12 日 上午 5:24 
como se instala esto???pon algun ejemplo porfavor o algun video seria mejor