Jump to content

Open Community  ·  421 members

Stardew Valley

Noob Modder - need help please


Taskmaster2

Recommended Posts

Hello anyone with modding skill. I am attempting to learn a little about modding Stardew Valley, and sending a letter seems like a simple way to do that. According to Stardew Valley Wiki (https://stardewvalleywiki.com/Modding:Common_tasks) it is a common task.

 

I have the entry method, and I've tapped into the "new day event" to determine if I need to send the letter, but I need to insert the letter into the mail database, if you will. I have some C# experience, but not all concepts.

 

Wiki:

 

"Use IAssetEditor to inject new mail into Data\Mail.xnb" That sounds simple, but so far I am not able to find any examples of doing this.

 

 

I would appreciate any insight or assistance. Thank you in advance.

Link to comment
Share on other sites

Hello! MissCoriel here,

 

Why don't you tell us what exactly you want to do for modding. Sending Letters in game doesn't need coding experience. As a matter of fact, a good amount of modding can be done without any coding at all.

Content Patcher can do that for you by simply doing the following in a content.json:

{

	"Format": "1.9",
	"Changes": [
	
		{
		
			"Action": "EditData",
			"Target": "Data/Mail",
			"Entries": {
			
				"Example_Mail": "This is a test mail.^^^ That is all^^^ From,^       Myself",
			},
		},
		
		{
		
			"Action": "EditData",
			"Target": "Data/Events/Farm",
			"Entries": {
			
				"9595959595/e 60367/u 1/x Example_Mail": "null",
				
			},
		},
		
	]
	
}

That will mail you that letter the day after you seen the opening event.

 

If you have an idea of what you want to do please let us know and also don't be afraid to join the Discord and meet us. It's pinned in the Forum.

 

 

<3

Link to comment
Share on other sites

Thank you for the reply. Since I am attempting to learn how to mod, via code, I prefer not to mess with anything other than SMAPI for now. I have some C# experience so after reviewing the source code from Mail Framework, I have managed to display a letter in the mailbox using SMAPI only. Digus, if you read this, thank you.

 

I do have some concerns though given my understanding is very limited. For example, if my MOD injects a letter into the mail assets, and then I use the addMailForTomorrow method to add that to the mailbox for the next day, and then the user uninstalls my MOD before reaching the next day, does that corrupt the save file? I certainly don't want to cause that! :)

 

Can a MOD save/load data directly so it can track state, such as already having sent the letter once?

 

Can you reference the pet name from a letter, instead of the player name?

 

Outside of issues like that, I think I have the basics working already. Again, thanks for the reply!

Link to comment
Share on other sites

 

 

if my MOD injects a letter into the mail assets, and then I use the addMailForTomorrow method to add that to the mailbox for the next day, and then the user uninstalls my MOD before reaching the next day, does that corrupt the save file?

As far as I know *since my mod Event Repeater uses addMailforTomorrow* there shouldn't be a problem. At worst a SMAPI error will go off and continue with the game.

 

 

 

Can a MOD save/load data directly so it can track state, such as already having sent the letter once?

The game does that already, if you have a Mail ID on it. You can test this by using the command `showmail` with Event Repeater. If your mail ID appears then it's all good.

 

 

 

Can you reference the pet name from a letter, instead of the player name?

Yes.. the game does this automatically using %pet in a dialogue:

"Mon": "Hey @, How is %pet doing.  It must be nice having a cool pet.",
Link to comment
Share on other sites

Awesome information. Thanks very much. I am not doing anything incredible with this mod, just some random junk mail... sort of funny, I hope, type stuff. Mostly just a learning exercise.

 

My mail is not triggered on an event, other than new day. using a 5% chance to send junk mail, and then from there randomly sending 1 that has not yet been sent, which based on my understanding, unless I save that internal state out, my MOD will only know about what has happened this session (since it has been running). I'd rather not have the same junk mail sent to the player over and over as it is only funny reading it once or twice. I hope I am being clear.

 

 

Aside from experience, where would I learn about "%pet" for example? Or learn available sound cueNames?

Link to comment
Share on other sites

If you look at this Pinned Forum Post, it will carry plenty of resources for most directions a mod can take. Use them wisely :3

 

Thanks. I read that post earlier, but I guess I did not go as deep as I should have on the Wiki. I now see the items for replacements, and that explains why "%horse" did not work Do you happen to know if there is an undocumented code for displaying the horse name, if the player happens to have one? Again thank you, and sorry if I am treating you like my personal Wiki!

Link to comment
Share on other sites

OK, so what I have found is that the game is remembering that a letter has been sent making it so I cannot send it again. That hampers my ability to debug. I cannot see the letter anymore to ensure that the text is accurate and so forth. I do not see anything obvious on the Game1 object, or in helper.events, etc. that appears to be a collection of sent mail Ids. It may be in the custom data collection, but since I cannot step through the code it is hard to validate this stuff. I'm not sure how I can clear the mail Ids so I can continue to verify the MOD.

 

For some reason using %pet or %farm do not work either in mail. The @ works fine. I just won't use them for this MOD.

 

For the working MOD having the mail not resend is fine, but for debugging and verification it is a pain. Obviously I can change all the mail Ids, but that is not ideal as it bloats where ever that is stored and is not optimal for development.

 

Anyway, I'm just a bit frustrated, so my apologies. By the way, would you be interested in being a guinea pig for this MOD?

Edited by Taskmaster2
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...