[ TOOL ] Mod Update Note - Send Mod Updated Note to your steam users!

Started by WalkingProblem, June 16, 2017, 05:31:50 PM

Previous topic - Next topic

WalkingProblem

If you are not using HugLibs and wondering how to let your spoiled steam users know that you just spent 100 hours on this latest mod update?

I'm proud to release my "Mod Update Note" codes! =D

This is the method I used to inform my users of the update in my StarshipTroopers Arachnid Mod : https://ludeon.com/forums/index.php?topic=32625.0

--------------




HOW TO DO THIS?


1) DLL

You will need a bit of C# to compile the DLL required for this update note (sorry, no easier way).

First you need an IncidentWorker to create the incident for the update note to be fired:

using System;
using System.Collections.Generic;
using Verse;

namespace RimWorld
{
    public class IncidentWorker_ArachnidUpdateNote : IncidentWorker
    {
        public override bool TryExecute(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            Find.LetterStack.ReceiveLetter("LetterLabelArachnidUpdate".Translate(), "ArachnidUpdate".Translate(new object[]
                {
                }), LetterDefOf.Good, null);
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            return true;
        }
    }
}

You need to change "IncidentWorker_ArachnidUpdateNote", "LetterLabelArachnidUpdate" and "ArachnidUpdate" to your own naming convention to avoid conflicts.

If you do not change the these parts, you will cause mod conflict with others (especially me, if you copy and paste without changing).

This C# code will just need to be create once for each mod, and you will never need to touch this again.


2) Incident XML

Create a xml file in your mod's Defs folder and name it anything you want: (mine is Incidents_Bugs.xml)

Open the xml file, and insert the below codes:

<Defs>
    <IncidentDef>
    <defName>ArachnidUpdateNote</defName>
    <label>arachnid mod 2.2 update note</label>
    <targetType>MapPlayerHome</targetType>
    <workerClass>IncidentWorker_ArachnidUpdateNote</workerClass>
    <baseChance>9999.0</baseChance>
    <category>Misc</category>
    <minRefireDays>10000</minRefireDays>
    <pointsScaleable>false</pointsScaleable>
<minThreatPoints>1</minThreatPoints>
  </IncidentDef>
</Defs>


For each update you release, you need to change the DefName. Maybe BlarBlarUpdateNote1, the next release, BlarBlarUpdateNote2.
This is important because, this Incident will only be fired once in a single game, and will never appear again. If you did not change to a new iteration for your new update, the Update Note incident will not fire in a saved game which already had the first Update Note from the previous mod version.

The Label will actually not be seen by the players. Its probably just a reminder for yourself.

And of course the workerClass, in which you will need to update to whatever the IncidentWorker name you have gave it, in the C# codes in Step 1.



3) Final Step: The Message itself

Very quickly, we are in the last step, this is where you write your actual note and letter to your fans/mod users.

Create an xml file in the Languages\English\Keyed\ folder. (if you are new to modding, Languages folder is on the same level as the Defs folder ; NOT IN the Defs folder. It MUST BE in this folder arrangement: Languages -> English -> Keyed , or your message will not appear. You can name your xml anything you want, mine is BugLanguage.xml

Open the xml, and insert in these codes:
<?xml version="1.0" encoding="utf-8" ?>
<LanguageData>
<LetterLabelArachnidUpdate>StarshipTroopers Arachnid 2.2 Released!</LetterLabelArachnidUpdate>
  <ArachnidUpdate>Your copy of StarshipTroopers Arachnid mod had just upgraded to 2.2!!!\n\nJust to reintroduce the additions into the StarshipTrooper Arachnid Mod since Version 2.0.\n\nBlar blar blar blar blar blar blar</ArachnidUpdate>
</LanguageData>


I'm sure you know without me saying, that you will need to replace the "LetterLabelArachnidUpdate" to the one you had entered in Step 1 in the C# code, as well as the main message part's "ArachnidUpdate".

The "LetterLabelArachnidUpdate" will be the main title which appears on the Letter Icon when the incident is fired, and the "ArachnidUpdate" is where your mod update notes goes. "\n\n" is how you go to the next line (line break).

You will not need to update the underlined parts for future updates, you just need to set it up once. You just need to update your content of the Update Note.

--------

Hope the above helps!

Feel free to join me on my Discord channel, especially if you have any questions for me: https://discord.gg/W2Vb27T

CHEERS!