Space Engineers Programming 101 - Inventory Manager Script - Part 1

Space Engineers Programming 101 - Inventory Manager Script - Part 1

Sleepless Knights Studios

10 лет назад

16,548 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@TheFont88
@TheFont88 - 20.03.2015 06:20

This series is really cool (as are the Space and Medieval Engineers ones)! Building the script as you go in the video like this can highlight problems people might run into while coding similar things on their own. If you have everything done before hand, then it becomes more of just an explanation. Both are fine, but i think the first way may have a bit more learning value for viewers. 

Ответить
@mrsusort
@mrsusort - 27.06.2015 23:42

I had the same problem when doing a script for energy left. The Wiki says uranium contains 0.0191 MWh, but that doesn't make sense when looking at the terminals time left. So i just changed the formula around (EnergyPerKg = (TimeLeft * CurrentOutput) / Total Ingots) and got around 1 MWh per kg, Love the series by the way, done a bit of programming in school, but not c# or with an api, so this series is really helpful.

Ответить
@markgcns
@markgcns - 23.08.2015 17:55

If you wouldn't mind sharing,, which "LCD Panel" mod are you using in this vid?

Ответить
@HPLOG3
@HPLOG3 - 18.09.2015 02:33

I don't know if you did, but I think you also have to factor in the timestep of the calculations ingame.
For example, the power consumption and distribution ingame maybe happens only once every seond.
But this isn't really necessary, as this should be just another fixed value and your ingame script also runs at a fixed value and should be synchronized.

the formula would be:
Time(h) = Uranium(kg)/Consumption(MW) * Ratio

you just need to figure out the "Ratio" part, which is basically, the effectivity of uranium or how much electricity it produces.
I highly doubt that the devs made it too complicated. In the real world you would have to factor in the quality of uranium and the efficiency of the reactor etc. In the game, it should just be a fixed value.

So if you have 1kg of uranium and a power consumption of 2MW and it would last you for 10 hours then "Ratio" would be 20.
You can calculate other values, or realtime values and see if it actually matches.

This would only apply if "Ratio" is linear, but I would be suprised if it wasn't.

Ответить
@CheronoSan
@CheronoSan - 20.10.2015 18:09

I am trying to make a script where I change the name of few connectors and containers and make a dispenser system where player choose a connector from which X amount of selected component will be dropped.
making name change script was easy but I have hard time accessing the inventory of the containers.
I have programming background with VB6 and java but C# is hard for me... it would be nice to have some help :)

Ответить
@spookyhammer1092
@spookyhammer1092 - 12.12.2015 05:27

I keep getting the "Object reference not set to an instance of an object" problem. And i checked my name of the LCD and everything.
It creates the instance fine though, it only shows this problem when i want to change something in it.
This is really getting annoying :/

Ответить
@arne.m8662
@arne.m8662 - 19.03.2016 13:04

How must name the LCD panels?

Ответить
@INGIE32
@INGIE32 - 10.04.2016 04:41

This video is one of the best tutorials that I have seen. Great job

Ответить
@MakarovFox
@MakarovFox - 27.05.2016 21:04

I made a script , but when I try to upload fails

Ответить
@williamconway9813
@williamconway9813 - 16.10.2016 19:12

"caught during execution of script: Object reference not set to instance of an object " what do I do

Ответить
@Cobraslaya290
@Cobraslaya290 - 15.12.2016 22:39

So I copied it to the best of my abilities and everything looks the same to me but for some reason it doesn't update the screen how can I fix this?

Ответить
@strom56
@strom56 - 19.08.2017 13:15

Its kind of annoying how Keen puts this coding stuff into the game but then doesn't give us a proper tutorial on how to use it I've never done a shred of coding to me its all double Dutch. It's Double Dutch that I really really want to understand.

Ответить
@MerlinMoorlo
@MerlinMoorlo - 21.06.2018 22:05

explain plz what does display.UpdateVisuals?

Ответить
@seanbryner5534
@seanbryner5534 - 08.03.2019 08:35

Can you help me with a problem in programmable block: After Run button there is a message " Assembly not found"

Ответить
@kindasupersonic7114
@kindasupersonic7114 - 19.04.2020 10:05

I have been having trouble with a script for the LCD to display how much of what is being mined on my mining platform.
echo
InvlistX T:* +ingot/iron,nickel,silicon -ore
Inventorylist {G:MMR Cargo Containers} +ore -scrap -iron -nickel -silicon +stone
echo
CargoAll {G:MMR Cargo Containers}


thats what i currently have.. but it never updates, despite whats being mined and held in the onboard containers.. please help

Ответить
@adamring5325
@adamring5325 - 13.05.2020 20:02

Realy helped. I have a great problem in survival when i make a drill to gather lotts of stone it fills upp all my cargo and just diggs untill the pistons are done. so i do need a scripts that sees if the cargo of stone is full the drill systems turns off.

Ответить
@adamring5325
@adamring5325 - 14.05.2020 11:10

void Main()
{

// Variables

IMyTextPanel display;



List<IMyTerminalBlock> crates = new List <IMyTerminalBlock>();



// Instantiation

display = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("LCD Inventory Display");



GridTerminalSystem.GetBlocksOfType<IMyCargoContainer>(crates);



// Display Data

display.WritePublicText(GetAllInv(crates), false);



// Update Visuals

display.ShowPublicTextOnScreen();

display.UpdateVisual();

}



string GetAllInv(List<IMyTerminalBlock> crates)

{

// Variables

string finalInvStr = "";



List<IMyInventoryItem> allItems = new List<IMyInventoryItem>();



// Get Inventories

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

{

var owner = (IMyInventoryOwner)crates[i];

var inventory = (IMyInventory)owner.GetInventory(0);

var items = inventory.GetItems();



allItems.AddRange(items);

}



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

{

finalInvStr += allItems[i].Content.SubtypeName + " = " + allItems[i].Amount + " (RAW): " + allItems[i].Amount.RawValue + "\n";

}

return finalInvStr;



}

Ответить
@adamring5325
@adamring5325 - 14.05.2020 11:15

I do get 3 errors. 1st. is Line 33. There is no argument given that corresponds the required formal parameter

2nd error. Cannot assign void to an implicity-typed variable.

3rd error, The type or member ´string MyObjectBuilder_Base.SubtypeName` is prohibited.

Ответить
@ASwedishTigress
@ASwedishTigress - 29.03.2023 01:42

Coming back to this. It is awesome, thank you so much.
You'll be included in my self biography if I survive the brain hemorrhage I get from programming in space engineers 😂

Ответить
@oleksandr4371
@oleksandr4371 - 16.11.2023 16:24

8 yeats later, this video still helps as I strugled to find out which part of API manage inventory, thank you

Ответить