1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

Assembly not found error

Discussion in 'Programming Questions and Suggestions' started by Ninta, Jan 19, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Ninta

    Ninta Trainee Engineer

    Messages:
    24
    ok so i was making my own program for refinery management but im running into a problem. the code listed below builds in VS2013 and the ingame check code function also says there are no issues but when i try to run it i get the error "Assembly not found. Please compile script". what can cause this error to apear? do i need to NOT use certain things i used like enumerators (and if so why does check code not warn about that?). any help would be welcomed.
    Code:
            void main()
            {
                List<refinery> refinerys = interfaceToStruct(getAllRefineries());
                List<container> cargocontainers = interfaceToStruct(getAllContainers());
                for(int c = 0; c < cargocontainers.Count; c++)
                {
                    IMyInventory inv = (cargocontainers[c].block as IMyInventoryOwner).GetInventory(0);
                    List<IMyInventoryItem> items = inv.GetItems();
                    for (int i = 0; i < items.Count; i++)
                    {
                        string itemType = items[i].Content.ToString().ToLower();
                        itemType = itemType.Substring(itemType.LastIndexOf('_') + 1);
                        ores type = toOresType(itemType);
                        if (type != ores.noOre)
                        {
                            List<refinery> targets = findAllowed(refinerys, type);
                            VRage.MyFixedPoint ammount = new VRage.MyFixedPoint();
                            ammount.RawValue = (long)Math.Floor((decimal)(items[i].Amount.RawValue / targets.Count));
                            for (int j = 0; j < targets.Count; j++)
                            {
                                IMyInventory targetInv = (targets[j].block as IMyInventoryOwner).GetInventory(0);
                                if(targetInv.MaxVolume.RawValue - targetInv.CurrentVolume.RawValue > ammount.RawValue)
                                {
                                    inv.TransferItemTo(targetInv, i, null, true, ammount);
                                }
                                else
                                {
                                    VRage.MyFixedPoint temp = new VRage.MyFixedPoint();
                                    temp.RawValue = targetInv.MaxVolume.RawValue - targetInv.CurrentVolume.RawValue;
                                    inv.TransferItemTo(targetInv, i, null, true, temp);
                                }
                            }
                        }
                    }
                }
            }
            public List<refinery> findAllowed(List<refinery> refineries, ores type)
            {
                List<refinery> allowed = new List<refinery>();
                for (int i = 0; i < refineries.Count; i++)
                {
                    if (refineries[i].allowedTypes.Contains(type)) allowed.Add(refineries[i]);
                }
                return allowed;
            }
            public List<container> findAllowed(List<container> containers, ingots type)
            {
                List<container> allowed = new List<container>();
                for (int i = 0; i < containers.Count; i++)
                {
                    if (containers[i].allowedTypes.Contains(type)) allowed.Add(containers[i]);
                }
                return allowed;
            }
            public List<IMyRefinery> getAllRefineries()
            {
                List<IMyTerminalBlock> functionalBlocks = new List<IMyTerminalBlock>();
                GridTerminalSystem.GetBlocksOfType<IMyRefinery>(functionalBlocks);
                List<IMyRefinery> refineries = new List<IMyRefinery>();
                for (int i = 0; i < functionalBlocks.Count; i++)
                {
                    refineries.Add(functionalBlocks[i] as IMyRefinery);
                }
                return refineries;
            }
            public List<IMyCargoContainer> getAllContainers()
            {
                List<IMyTerminalBlock> functionalBlocks = new List<IMyTerminalBlock>();
                GridTerminalSystem.GetBlocksOfType<IMyRefinery>(functionalBlocks);
                List<IMyCargoContainer> cargoContainers = new List<IMyCargoContainer>();
                for (int i = 0; i < functionalBlocks.Count; i++)
                {
                    cargoContainers.Add(functionalBlocks[i] as IMyCargoContainer);
                }
                return cargoContainers;
            }
            public List<refinery> interfaceToStruct(List<IMyRefinery> refList)
            {
                List<refinery> refs = new List<refinery>();
                for (int i = 0; i < refList.Count; i++)
                {
                    IMyRefinery r = refList[i];
                    refinery Refi = new refinery();
                    Refi.allowedTypes = new List<ores>();
                    Refi.block = r;
                    Refi.isFull = false;
                    if (!r.CustomName.Contains("All"))
                    {
                        if (r.CustomName.Contains("cobalt")) Refi.allowedTypes.Add(ores.cobalt);
                        if (r.CustomName.Contains("gold")) Refi.allowedTypes.Add(ores.gold);
                        if (r.CustomName.Contains("stone")) Refi.allowedTypes.Add(ores.stone);
                        if (r.CustomName.Contains("iron")) Refi.allowedTypes.Add(ores.iron);
                        if (r.CustomName.Contains("magnesium")) Refi.allowedTypes.Add(ores.magnesium);
                        if (r.CustomName.Contains("nickel")) Refi.allowedTypes.Add(ores.nickel);
                        if (r.CustomName.Contains("platinum")) Refi.allowedTypes.Add(ores.platinum);
                        if (r.CustomName.Contains("silicon")) Refi.allowedTypes.Add(ores.silicon);
                        if (r.CustomName.Contains("silver")) Refi.allowedTypes.Add(ores.silver);
                        if (r.CustomName.Contains("uranium")) Refi.allowedTypes.Add(ores.uranium);
                    }
                    else Refi.allowedTypes = allOres;
                    IMyInventory inv = (r as IMyInventoryOwner).GetInventory(0);
                    if (inv.CurrentVolume.RawValue / inv.MaxVolume.RawValue > 0.9) Refi.isFull = true;
                    refs.Add(Refi);
                }
                return refs;
            }
            public List<container> interfaceToStruct(List<IMyCargoContainer> cargoList)
            {
                List<container> refs = new List<container>();
                for (int i = 0; i < cargoList.Count; i++)
                {
                    IMyCargoContainer r = cargoList[i];
                    container cont = new container();
                    cont.block = r;
                    cont.isFull = false;
                    cont.allowedTypes = new List<ingots>();
                    if (!r.CustomName.Contains("Ingots"))
                    {
                        if (r.CustomName.Contains("cobalt")) cont.allowedTypes.Add(ingots.cobalt);
                        if (r.CustomName.Contains("gold")) cont.allowedTypes.Add(ingots.gold);
                        if (r.CustomName.Contains("gravel")) cont.allowedTypes.Add(ingots.gravel);
                        if (r.CustomName.Contains("iron")) cont.allowedTypes.Add(ingots.iron);
                        if (r.CustomName.Contains("magnesium")) cont.allowedTypes.Add(ingots.magnesium);
                        if (r.CustomName.Contains("nickel")) cont.allowedTypes.Add(ingots.nickel);
                        if (r.CustomName.Contains("platinum")) cont.allowedTypes.Add(ingots.platinum);
                        if (r.CustomName.Contains("silicon")) cont.allowedTypes.Add(ingots.silicon);
                        if (r.CustomName.Contains("silver")) cont.allowedTypes.Add(ingots.silver);
                        if (r.CustomName.Contains("uranium")) cont.allowedTypes.Add(ingots.uranium);
                    }
                    else cont.allowedTypes = allIngots;
                    IMyInventory inv = (r as IMyInventoryOwner).GetInventory(0);
                    if (inv.CurrentVolume.RawValue / inv.MaxVolume.RawValue > 0.9) cont.isFull = true;
                    refs.Add(cont);
                }
                return refs;
            }
            public ores toOresType(string type)
            {
                ores oreType;
                switch(type)
                {
                    case "cobalt":
                        oreType = ores.cobalt;
                        break;
                    case "gold":
                        oreType = ores.gold;
                        break;
                    case "iron":
                        oreType = ores.iron;
                        break;
                    case "magnesium":
                        oreType = ores.magnesium;
                        break;
                    case "nickel":
                        oreType = ores.nickel;
                        break;
                    case "platinum":
                        oreType = ores.platinum;
                        break;
                    case "silicon":
                        oreType = ores.silicon;
                        break;
                    case "silver":
                        oreType = ores.silver;
                        break;
                    case "stone":
                        oreType = ores.stone;
                        break;
                    case "uranium":
                        oreType = ores.uranium;
                        break;
                    default:
                        oreType = ores.noOre;
                        break;
                }
                return oreType;
            }
            public ingots toIngotsType(string type)
            {
                ingots oreType;
                switch (type)
                {
                    case "cobalt":
                        oreType = ingots.cobalt;
                        break;
                    case "gold":
                        oreType = ingots.gold;
                        break;
                    case "iron":
                        oreType = ingots.iron;
                        break;
                    case "magnesium":
                        oreType = ingots.magnesium;
                        break;
                    case "nickel":
                        oreType = ingots.nickel;
                        break;
                    case "platinum":
                        oreType = ingots.platinum;
                        break;
                    case "silicon":
                        oreType = ingots.silicon;
                        break;
                    case "silver":
                        oreType = ingots.silver;
                        break;
                    case "gravel":
                        oreType = ingots.gravel;
                        break;
                    case "uranium":
                        oreType = ingots.uranium;
                        break;
                    default:
                        oreType = ingots.noIngot;
                        break;
                }
                return oreType;
            }
            public List<ores> allOres = new List<ores>()
            {
                ores.cobalt,
                ores.gold,
                ores.iron,
                ores.magnesium,
                ores.nickel,
                ores.platinum,
                ores.silicon,
                ores.silver,
                ores.stone,
                ores.uranium
            };
            public List<ingots> allIngots = new List<ingots>()
            {
                ingots.cobalt,
                ingots.gold,
                ingots.iron,
                ingots.magnesium,
                ingots.nickel,
                ingots.platinum,
                ingots.silicon,
                ingots.silver,
                ingots.gravel,
                ingots.uranium
            };
            public struct refinery
            {
                public IMyTerminalBlock block;
                public List<ores> allowedTypes;
                public bool isFull;
            }
            public struct container
            {
                public IMyTerminalBlock block;
                public List<ingots> allowedTypes;
                public bool isFull;
            }
            public enum ores
            {
                cobalt,
                gold,
                stone,
                iron,
                magnesium,
                nickel,
                platinum,
                silicon,
                silver,
                uranium,
                noOre
            }
            public enum ingots
            {
                cobalt,
                gold,
                gravel,
                iron,
                magnesium,
                nickel,
                platinum,
                silicon,
                silver,
                uranium,
                noIngot
            }
    
    PS: yes i know i do some things in a roundabout way thats inefficient. this is just the first itteration of the script before i clean it up and optimize it.
     
    Last edited by a moderator: Jan 19, 2015
  2. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    did you press Save and Compile button in Editor?

    atm, Main, not main
     
    Last edited by a moderator: Jan 19, 2015
  3. Ninta

    Ninta Trainee Engineer

    Messages:
    24
    changed main to Main but i can not found a save and compile button in the editor. i got a screenshot here from what i can see:
    https://i.imgur.com/ww6m7or.png?1
     
  4. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    mistranslating, sorry.

    press Check and then Remember & Exit
     
  5. Ninta

    Ninta Trainee Engineer

    Messages:
    24
    yea thats what i did. ive managed to get some compiler errors to show by clicking remember and exit after i changed the ownership of the block and it was talking about underlying type of an enumerator. replaced the enumerator (adding a type to it did nothing) and now im getting some dictionary errors so im going somewhere

    seems to me using enumerators is NOT supported.
     
Thread Status:
This last post in this thread was made more than 31 days old.