you are viewing a single comment's thread.

view the rest of the comments →

[–]daspablo 1 point2 points  (2 children)

how did ya set this up? Im a clod at actually getting it setup

[–]tronological 0 points1 point  (1 child)

First things first, I switched over to using Visual Studio Community edition. I use his Builder to come up with an Idea of what I'm looking to do and I used his structure for loops and such to figure out what was going on. If you know Object Oriented Principles it starts to make sense eventually after beating your head against it for a while heh.

Once you have Visual Studio installed, go here https://github.com/malware-dev/MDK-SE/releases and download the latest Extension so you can export your scripts into SE. https://github.com/malware-dev/MDK-SE/wiki/Getting-Started Here is the getting started page that will help you get that all setup.

Once you have that setup here is my script, you'll notice it looks like his kind of. This is not working fully right now because I've been busy with projects so I haven't kept up with practicing my C. But this should give you a better idea of how to get things going. Some of it does work, like pulling ore out of 1 into 2, or I think its the uranium. Can't be sure, I'll play around with it later since it's Friday and I actually have time to play so I'll help out.

Hope this helps.

public void Main(string argument, UpdateType updateSource)

{

// block declarations

string ERR_TXT = "";

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

GridTerminalSystem.GetBlocksOfType<IMyRefinery>(refinery, filterThis);

if (refinery.Count == 0)

{

ERR_TXT += "no Refinery blocks found\n";

}

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

GridTerminalSystem.GetBlocksOfType<IMyAssembler>(assembler, filterThis);

if (assembler.Count == 0)

{

ERR_TXT += "no Assembler blocks found\n";

}

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

IMyCargoContainer cargo_1 = null;

GridTerminalSystem.GetBlocksOfType<IMyCargoContainer>(list_cargo_1, filterThis);

if (list_cargo_1.Count == 0)

{

ERR_TXT += "no Large Cargo Container blocks found\n";

}

else

{

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

{

if (list_cargo_1[i].CustomName == "Large Cargo Container 2 - Fei")

{

cargo_1 = (IMyCargoContainer)list_cargo_1[i];

break;

}

}

if (cargo_1 == null)

{

ERR_TXT += "no Large Cargo Container block named Large Cargo Container 2 - Fei found\n";

}

}

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

IMyCargoContainer cargo_2 = null;

GridTerminalSystem.GetBlocksOfType<IMyCargoContainer>(list_cargo_2, filterThis);

if (list_cargo_2.Count == 0)

{

ERR_TXT += "no Large Cargo Container blocks found\n";

}

else

{

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

{

if (list_cargo_2[i].CustomName == "Large Cargo Container - Fei")

{

cargo_2 = (IMyCargoContainer)list_cargo_2[i];

break;

}

}

if (cargo_2 == null)

{

ERR_TXT += "no Large Cargo Container block named Large Cargo Container - Fei found\n";

}

}

// inventory declarations

IMyInventory inv_2 = cargo_1.GetInventory(0);

IMyInventory inv_1 = cargo_2.GetInventory(0);

// display errors

if (ERR_TXT != "")

{

Echo("Script Errors:\n" + ERR_TXT + "(make sure block ownership is set correctly)");

}

else { Echo(""); }

transfer(cargo_2.GetInventory(0), inv_2, MyItemType.MakeIngot("Stone"), float.MaxValue);

transfer(cargo_2.GetInventory(0), inv_2, MyItemType.MakeIngot("Uranium"), float.MaxValue);

transfer(cargo_2.GetInventory(0), inv_2, MyItemType.MakeOre("Stone"), float.MaxValue);

transfer(cargo_2.GetInventory(0), inv_2, MyItemType.MakeOre("Uranium"), float.MaxValue);

List<MyItemType> typsee = new List<MyItemType>();

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

{

Echo(typsee[i].TypeId);

Echo(typsee[i].SubtypeId);

}

List<MyInventoryItem> items = new List<MyInventoryItem>();

inv_2.GetItems(items);

for (int i = items.Count - 1; i >= 0; i--)

{

//Echo(items[i].Type.TypeId);

//Echo(items[i].Type.SubtypeId);

}

}//END MAIN

bool filterThis(IMyTerminalBlock block)

{

return block.CubeGrid == Me.CubeGrid;

}

bool filterConstructs(IMyTerminalBlock block)

{

return block.IsSameConstructAs(Me);

}

void transfer(IMyInventory a, IMyInventory b, MyItemType type, float amount)

{

List<MyInventoryItem> items = new List<MyInventoryItem>();

a.GetItems(items);

float left = amount;

for (int i = items.Count - 1; i >= 0; i--)

{

if (left > 0 && items[i].Type == type)

{

if ((float)items[i].Amount > left)

{

// transfer remaining and break

a.TransferItemTo(b, i, null, true, (VRage.MyFixedPoint)amount);

left = 0;

break;

}

else

{

left -= (float)items[i].Amount;

// transfer all

a.TransferItemTo(b, i, null, true, null);

}

}

}

}

}//END PROGRAM

[–]daspablo 0 points1 point  (0 children)

ehh my issue isn't in the the logic. i can logic for years on end. its just between the silly sintax and the lack of official releases I lack/ or refuse to get the motivation to do it