Modding Help How can I change the code to work correctly?

Discussion in 'Mods' started by jae ha, Dec 26, 2019.

Thread Status:
Not open for further replies.
  1. jae ha

    jae ha Seal Broken

    Code:
     public class ModEntry : Mod
        {
            Dictionary<ISalable, int[]> d1;
            bool firstRun = true;
            public override void Entry(IModHelper helper)
            {
                helper.Events.Display.MenuChanged += OnMenuChanged;
                helper.Events.GameLoop.DayStarted += OnDayStarted;
            }
            private void OnDayStarted(object sender, DayStartedEventArgs e)
            {
                d1 = null;
                firstRun = true;
            }
            private void OnMenuChanged(object sender, MenuChangedEventArgs e)
            {
                //check shopmenu
                if (e.NewMenu is ShopMenu menu)
                {
                    ShopMenu shopmenu = menu;
                    //check info               
                    this.Monitor.Log($"today : {Game1.year}, {Game1.currentSeason}. who : {shopmenu.portraitPerson.Name}", LogLevel.Debug);
                    if (shopmenu.portraitPerson.Name.Equals("Pierre"))
                    {
                        if (Game1.year <= 3 && firstRun == true)
                        {
                            var target = shopmenu.itemPriceAndStock.ToList();
                            for (int i = 0; i < shopmenu.itemPriceAndStock.Count; i++)
                            {
                                if (target[i].Key.Name.Contains("Seeds"))
                                {
                                    target[i].Value[1] = 5;
                                    shopmenu.forSale[i].Stack = 5;
                                }
                                this.Monitor.Log($"이거 뭐임 타입 : {target[i].Key.GetType()}", LogLevel.Debug);
                                this.Monitor.Log($"이거 뭐임2 : {target[i].Key.Name}", LogLevel.Debug);
                            }
                            d1 = shopmenu.itemPriceAndStock;
                            firstRun = false;
                        }
                       
                        if(firstRun == false) 
                        { 
                        shopmenu.setItemPriceAndStock(d1);
                        }
                    }
                }
            }
        }
    

    I want to make Pierre sell 5 seeds a day like Krobus's store.(or like a Traveling Cart)
    So I wrote the code that way.


    But if you write code like that
    "Tulip Bulb" or
    This does not apply to seeds such as "Bean Starter".
    I want to apply it properly as a value that distinguishes Seeds from Object.
    How do I change the code?
    Please help
    I'm not good at English so I wrote it through Google Translate.
    It's hard to reply
    I appreciate the people who give me all the comments. Thank you



    I'm not good at English so I wrote it through the translator. I appreciate all the people who reply.


    if (target.Key.Name.Contains("Seeds")) ←←←←← I don't want to separate this part by name using "Contains". How should I change it?
     
      Last edited by a moderator: Dec 27, 2019
    • Iris Blanche

      Iris Blanche Pudding Paradox Forum Moderator

    Thread Status:
    Not open for further replies.

    Share This Page