RELEASED BirthdayMail 1.2.1

Adds mail from mayor Lewis to remind you of birthdays.

  1. Kitta

    Kitta Void-Bound Voyager

    Kitta submitted a new mod:

    BirthdayMail - Adds mail from mayor Lewis to remind you of birthdays.

    Read more about this mod...
     
    • SasuraUchiha

      SasuraUchiha Cosmic Narwhal

      Nice! Will try it out!
       
      • Entoarox

        Entoarox Oxygen Tank

        Might I suggest you tryto subscribe to `Player.LoadedGame` to see if it fixes your issue, because I do believe that `TimeEvents.DayOfMonthChanged` is triggered before the game is saved, thus it wont get triggered on load.
         
          Kitta likes this.
        • Nurio

          Nurio Cosmic Narwhal

          Not having any experience with modding this game, I could've sworn there was also something like TimeEvents.NewDay or something like that... That triggers on the start of a new day when you wake up, I believe
           
          • Entoarox

            Entoarox Oxygen Tank

            Actually, that event triggers twice a day, once just before saving (with the `newDay` argument set to true) and once directly after saving (this time the `newDay` argument will be false)
            But it wont trigger on loading a game.
             
            • Kitta

              Kitta Void-Bound Voyager

              Actually, from my testing, it does trigger. The odd part is that even though it runs all the way to the adding mail part, the mail doesn't actually get queued inside the mailbox.
              I will look at PlayerEvents.LoadedGame and get that to work. Thanks for a great suggestion!
               
              • Kitta

                Kitta Void-Bound Voyager

                Alright, sadly this produces the same problem: the functions run, the mail gets added (or at least the code for adding it runs) but the mailbox does not have the enqeueu'd item...
                 
                • Kitta

                  Kitta Void-Bound Voyager

                  The more i test this, the less sence it makes. It seems that even when i delay the action of adding the mailbox item, it doesn't add it when ran inside Event_DayOfMonthChanged, but adding the mailbox item manually (with a KeyDown event) works just fine...
                  And again, all of these issues only happen on the first load if the mod had not been installed previously...

                  Its a very minor problem.... but regardless it is annoying, and the more i dig into this the more confusing things get.
                   
                  • Kitta

                    Kitta Void-Bound Voyager

                  • Kitta

                    Kitta Void-Bound Voyager

                  • Nurio

                    Nurio Cosmic Narwhal

                    Kitta likes this.
                  • Kitta

                    Kitta Void-Bound Voyager

                    Indeed i have. I tested out a lot of things and studied the way the functions run and in what structure (all guess work as there is no actual source code or documentation for the game itself). After a long time, i concluded that the DayOfMonthChanged has to be running before the game has loaded all farm information. That process also apparently included multiple UpdateTicks which is why using it for a delayed reaction to set the first update was not working either. I looked through the GameEvents in StardevModdingAPI, and knowing i will need something that will run 100% independently of the loading functions i decided to use the OneSecondTick. Turned out i was right, as running the script inside an independent event like the OneSecondTick made sure that all loading was done first before my script tried to acess the current Game1 information.

                    if you would like to look at my code here is a direct link to the script on GitHub. Feel free to read through my comments if it helps you understand it better: https://github.com/KathrynHazuka/StardewValley_BirthdayMail/blob/master/BirthdayMail/Main.cs
                     
                      Nurio likes this.
                    • Nurio

                      Nurio Cosmic Narwhal

                      Very nice! One question, though.
                      Why do you have both a firstUpdate and Initialupdate boolean? (And shouldn't that be initialUpdate as a convention?)
                      If I read the code correctly, you could easily do this with just firstUpdate, right?

                      So... Like this. (I rewrote it a bit to fit my own coding style, fixed the villeger typo, and only included the relevant methods and fields.) I also added a comment of my own to the Event_OneSecondTick method
                      Code:
                      private bool firstUpdate = true;
                      
                      private NPC birthdayNPC; // NPC object of the villager who has a birthday
                      private string birthdayMail; // birthday mail item that corresponds to this NPC
                      
                      public override void Entry(params object[] objects) {
                          // submit to events in StardewModdingAPI
                          StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += Event_DayOfMonthChanged;
                      }
                      
                      // runs once per second from the start of the game
                      // used for first update to solve the mail not being sent on initial load when adding the mod
                      private void Event_OneSecondTick(object sender, EventArgs e) {
                          // if this is the first update... (You won't even need this check, right? Since this only runs when firstUpdate == true in Even_DayOfMonthChanged)
                          if (firstUpdate) {
                              // ...check for birthdays and send mail
                              BirthdayMail();
                              firstUpdate = false;
                              // ...unsubmit from this event for optimization.
                              StardewModdingAPI.Events.GameEvents.OneSecondTick -= Event_OneSecondTick;
                          }
                      }
                      
                      // runs when the day changes
                      private void Event_DayOfMonthChanged(object sender, EventArgs e) {
                          // if this is the first update...
                          if (firstUpdate) {
                              // subscribe the Event_OneSecondTick() function to the OneSecondTick event
                              StardewModdingAPI.Events.GameEvents.OneSecondTick += Event_OneSecondTick;
                          } else {
                              // otherwise check for birthdays and send mail as usual
                              BirthdayMail();
                          }
                      }
                       
                        Kitta likes this.
                      • Kitta

                        Kitta Void-Bound Voyager

                        I have made the changes to code as you described. I also removed the if() inside the Event_OneSecondUpdate. all of these things were in there because of testing, and i just forgot to clean it up. the InitialUpdate having upper case I was just from being immensely tired after basically an entire day of testing things out... it should have been initialUpdate like you mentioned.

                        Thanks for pointing these out. I credited you on the GitHub readme credits for minor code cleanup help: https://github.com/KathrynHazuka/StardewValley_BirthdayMail/blob/master/README.md

                        Also, although it is 100% your opinion how code is written to be aesthetically pleasing, the standard is to separate blocks of code to clearly see individual lines for {}. this makes clocks easier to distinguish and read with large cods snippets, and prevents the code from looking a bit messy (which combining the {} into other lines does). Because of things like unity being something people usually begin with when making games, Monodevelop way of aesthetics is what rubs off on most beginners. I was on that boat once too before i was told otherwise. (not to say you are doing this because of unity, just stating that a lot of people have this format in their head from the start in general and then its harder for them to switch to standard conventional formatting)

                        Please consider using block format as it makes code easier to read. Things blend in too much when you have larger scripts when using the format you posted. (and to me it blends in already in a small script like yours, especially when there is no color coding applied)

                        Thanks.
                         
                          Nurio likes this.
                        • Nurio

                          Nurio Cosmic Narwhal

                          Wow, thanks for the credit!

                          And yeah, I have very little experience with coding, though I never touched Unity. I started with a Casio calculator, making games on that (I feel like Iwata, heh), and moved on to Javascript. Now it's Java for me.
                          I've been doing it for about 12 years, but I've actually not done much of it. It's just spread very thin, heh

                          But hm, I didn't know that having the curly braces on separate lines was a standard convention. I always thought that was a style up to the programmer himself. I'll consider changing! (I'd much rather adjust myself to a convention than being the offbeat with my own style I like :p)
                           
                          • Kitta

                            Kitta Void-Bound Voyager

                            it is considered conventional in c# along with many other languages in the professional field. It stems from much older languages. Its nothing you will NEED to do... but its just not looked at nicely, just like it isn't when looking at unconventional naming styles. I just wanted to let you know because i feel like following the standard is useful in more than just aesthetics.

                            And no problem about the credit. Happy to do something in return even though all i can really do is to give credit for your time.

                            Also it feels good when others take note of what i do, and you were here from day 1. Its not much from the outside, but to me that means a lot.
                             
                              Nurio likes this.
                            • Nurio

                              Nurio Cosmic Narwhal

                              I checked the mail.yaml file today and found, err... a few lingual errors. I've corrected them, and I want to ask you if it's okay if I upload the mail.xnb file.
                              There are also a few things I was uncertain about. But first, a list of changes:

                              For someone working as a doctor, it sure is odd to see him at the salon so often with a drink in his hand...
                              For someone working as a doctor, it sure is odd to see him at the saloon so often with a drink in his hand...

                              The boy acts tough sometimes, but he really is sweat when he wants to.
                              The boy acts tough sometimes, but he really is sweet when he wants to be.

                              Such a healthy girl, working hard every day.
                              She's such a healthy girl, working hard every day.

                              No wonder she looks so thin and strong!
                              No wonder she looks so slim and strong!
                              // Thin implies unhealthy, whereas slim is a more positive body figure

                              I saw her sneeking into the mines at one point.
                              I saw her sneaking into the mines at one point.

                              A very fragile girl, but with such a strong heart...
                              She's a very fragile girl, but with such a strong heart...
                              // Dropping the subject and main verb sounds too poetic for a letter like this

                              So peacefull...
                              So peaceful...

                              I wanted to remind you that today is Demetrius's birthday.
                              I wanted to remind you that today is Demetrius' birthday.
                              // For consistency. Every other name ending with an s has only an apostrophe when in possessive form

                              He just sits in the mines all day and night doesn't he?
                              He just sits in the mines all day and night, doesn't he?

                              She must love her red shirt.
                              She must love her red dress.
                              // Her sprite looks like she's wearing a dress, not a shirt

                              Such an old sweet lady.
                              Such a sweet old lady.
                              // Proper word order

                              Very steriotypical if you ask me, and thats why she is so lovely to be around!
                              Very stereotypically so, if you ask me. And that's why she is so lovely to be around!
                              // If you just say it's stereotypical, it sounds like a negative remark. Saying she's stereotypically sweet sounds a lot better

                              An old man with an old taste pallet.
                              He's an old man and his taste in food is even older!
                              // Else he has such a short description. Kinda sad...

                              I would guess he is from mexico... but i really can't really tell.
                              I would guess he is from Mexico... but I really can't tell.

                              I hope she grows up to be as pretty and happy as she is now.
                              I hope she'll grow up as pretty and happy as she is now.
                              // When someone grows up "to be" something, it implies a change, but this is a wish she stays the same level of prettiness and happiness

                              like the void itself...
                              Like the void itself...

                              I know you might think it is selfish of me to remind you that... but i like gifts too!
                              I know you might think it is selfish of me to remind you of that... but I like gifts too!

                              I wish he would understand that we welcome him more than he would like to accept...
                              I wish he would understand that we welcome him more than he thinks...
                              // I'm not even sure what the original line meant

                              That lady spends way too much time in the salon, don't you think?
                              That lady spends way too much time in the saloon, don't you think?

                              Our town would suffer greatly at his loss.
                              Our town would suffer greatly from his loss.

                              lets hope that Joja mart never gets to him...
                              Let's hope that Joja Mart never gets to him...

                              She works hard on all of her projects, and I heard she wanted to get goats at some point.
                              She works hard on all of her projects, and I heard she wanted to have goats at some point.

                              I Wonder is she still wants them...
                              I wonder if she still wants them...

                              amazing!
                              Amazing!

                              If I had to guess, i'd say he moved in right after college, but I know better than that.
                              If I had to guess, I'd say he moved in right after college, but I know better than that.

                              His mother should really go easy on him, she seems a bit over protective don't you agree?
                              His mother should really go easy on him. She seems a bit overprotective, don't you agree?

                              Man of the sea.
                              He's a man of the sea.

                              I just hope i won't have to go into his shop anytime soon.
                              I just hope I won't have to go into his shop any time soon.
                              // Anytime = adverb that doesn't mix with soon. The right adverbial phrase is "any time soon"


                              There were also a few phrases that sounded odd or awkward to me, but I didn't dare change them. Here they are:

                              You can't get strong like him without eating some nutritious meals!
                              // I get what you're saying, that you need nutrition to grow strong, but it's worded a bit awkwardly like this

                              She often walks around in summer time, picking up some flowers.
                              // "Some" flowers. Would probably be better to just say she's picking flowers instead of picking up some flowers
                              // And picking "up" implies they're just lying on the ground

                              He sure is a man of his own work!
                              // I'm not sure what this means... That he is an honest guy who works hard?
                              // I've heard of "a man of his word", but not "a man of his own work"

                              I heard that spring fruits really sing to his soul!
                              // Sing to his soul? Never heard of that expression!

                              I heard the military gave them nuts for breakfast!
                              // What?

                              That lady spends way too much time in the saloon, don't you think?
                              // That's awfully judgmental. And gossipy towards someone who just moved into town!

                              Our town would suffer greatly from his loss.
                              // Kinda makes it sound like the guy could die any minute...

                              Let's hope that Joja Mart never gets to him...
                              // "Gets to him" doesn't sound quite right


                              What are your thoughts on these?
                               
                              • Kitta

                                Kitta Void-Bound Voyager

                                I thought that adding the poetic format would be nice to mix up the standard "She's... He's..." format, and for an older man like Lowis, i think it fits well. Gosip is also part of a small town and i feel like Lowis would take part in it to some extent. It is however more of an observation than a judgment.

                                The saloon is what it is... a saloon. http://stardewvalleywiki.com/The_Stardrop_Saloon

                                Also as for some of the odd sounding ones, they actually contain hints for what the character likes as a gift... buts its something players will have to figure out on their own :p

                                As for other corrections i agree. You can upload the mail.xmb and i will check it. Make sure to upload it to a separate branch. I will give you permission on github when it comes up.

                                Thank you for your hard work... i don't know why you took your personal time to help me make this mod better... but i greatly appreciate it!!!!
                                 
                                  Last edited: Apr 17, 2016
                                • Nurio

                                  Nurio Cosmic Narwhal

                                  On second thought, I agree. I didn't talk much with Lewis prior to these corrections, but the poetic tone makes more sense now that I know him a bit better.

                                  Ah. But it says salon, not saloon, in the mail.xnb file

                                  I am a perfectionist who likes to squash typos. And because of your positive and welcoming attitude, I felt even more inclined to contribute

                                  EDIT: Forgot to mention. I'm not at my own computer right now. When I get home tonight, I'll upload the new mail.xnb
                                   
                                    Kitta likes this.
                                  • Kitta

                                    Kitta Void-Bound Voyager

                                    Ah. for some reason i thought it was reverse ... don't ask me how i thought that for just that one... im tired working on my other projects haha :p

                                    I will always be positive and welcoming to those who appreciate, criticize, or improve on my work, and you have done all of those and i am grateful to have someone like you following the progress of this mod from the start. Its a pleasure to know my work is being noticed and even taken care of by someone other than me.

                                    Also, check out this person's video / channel. They were nice enough to cover my mod in their video! its a humble mention but least i can do it give him a view or two:
                                     

                                    Share This Page