Issue Need some help tying a door unlocking to receiving a letter.

Jeebie99

Newcomer
I've been (slowly) making a mod for a couple weeks now, and I'm trying to figure out if I could make it so a locked door unlocks after receiving a letter (basically the same as when you first gain access to the Wizard Tower). I've got a custom tile sheet and the door is already placed on the map, but I just need to have it become unlocked after getting a letter. I tried digging around to figure out how the Wizard Tower unlocking is tied to his letter, but I couldn't find anything. Any help is appreciated! Also, I've been doing everything through content packs, so if its possible that way, that would be awesome.
 

mouse

Farmer
This can be done a few different ways, but Content Patcher makes it pretty simple (at least, if you are already used to it!). The Wizard's door is checked manually in the game code, but CP lets you make all your changes/additions to game assets dependent on all kinds of conditions -- including stuff like whether you've received a particular letter.

So you could easily combine a simple map edit with the HasFlag or HasReadLetter tokens to conditionally change a tile's properties. Example:
Code:
      {
         "Action": "EditMap",
         "Target": "Maps/Forest",
         "MapTiles": [
            {
               "Position": { "X": 90, "Y": 15 },
               "Layer": "Buildings",
               "SetProperties": {
                  "Action": "Dialogue @ keep out!"
               }
            }
         ],
         "When": "HasFlag |contains=mouse_MyCoolLetter": "false"
      }
should theoretically set Marnie's door to, instead of warping you, pop up a messaging saying, "<farmername> keep out!" unless you have received the mail called mouse_MyCoolLetter or otherwise been given that flag (like, say, during an event). On the map file itself you could just use keep the normal LockedDoorWarp.

(I just wrote this in the post and haven't tested it, so it's totally possible there is an error in it, but that's the general idea :P Feel free to ask if anything is unclear or you wanted to do it a different way, etc. The modding channels of the Stardew Valley Discord server are also much more active and are very helpful.)
 

mouse

Farmer
(Keep in mind too that each client is typically handling all kinds of stuff on its own -- is this something that all players will receive, or is it something that is tracked only by the host? Depending on how you have set up the conditions for opening the door, you might also need to throw in a hostPlayer somewhere in the condition to make sure it works for the right people :) {{HasSeenEvent: hostPlayer |contains=0000}}" should (theoretically, again) check only the host player's events to see if they've seen 0000 to meet whatever the sample condition was used for, for example. That's not always what you want, so it's just something to be aware of.)
 

Jeebie99

Newcomer
Works like a charm! Thank you so much, it was giving me a real headache trying to figure it out yesterday haha.
 
Top