Custom trader, Haplo I need help!

Started by skullywag, March 22, 2015, 04:20:46 PM

Previous topic - Next topic

skullywag

still stuck on this for anyone who can help.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

BBream

In 'TraderKindDef', stockGenerators maybe not initialized.

Add this line. I hope it works

traderKindDef.stockGenerators = new List<StockGenerator>;

skullywag

tried this:


private TradeShip TryGenerateOmniCorpTrader()
        {
            TraderKindDef traderKindDef = new TraderKindDef();
            StockGenerator_SingleDef sdef = new StockGenerator_SingleDef();
            sdef.HandlesThingDef(ThingDef.Named("Silver"));
            sdef.countRange.min = 2400;
            sdef.countRange.max = 3600;
            traderKindDef.stockGenerators = new List<StockGenerator>();
            traderKindDef.stockGenerators.Add(sdef);
            traderKindDef.label = "OmniCorp";
            traderKindDef.description = "An OmniCorp Trade Drone";
            Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver);
            traderKindDef.WillTrade(silver);
            return new TradeShip(traderKindDef);
        }


same error :(
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

skullywag

I cant complete this mod without the source of StockGenerator.GenerateThings, whatever this does i cannot replicate no matter how hard i try. I am sad panda... :(
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

BBream

#19
This is successfully functioned code. It generate slaves. Thanks you! You give me hint for this code


        public override IEnumerable<Thing> GenerateThings()
        {
            StringBuilder sb = new StringBuilder();
            List<Thing> things = new List<Thing>();
            //ThingDef thingDef = DefDatabase<ThingDef>.GetNamed("Human");

            for(int i = 0; i < RandomCountOf(PawnKindDefOf.Slave.race); i++)
            {
                Thing thing = PawnGenerator.GeneratePawn(PawnKindDefOf.Slave, Faction.OfColony);
                things.Add(thing);
                sb.AppendLine(thing.Label);
                Log.Message("thing:" + thing.ThingID);
            }

            Log.Message("StockGenerator_Animals:");
            Log.Message(sb.ToString());
            return things as IEnumerable<Thing>;
        }