Migrating your mod to Steam Workshop

If you have a mod written for Game Dev Tycoon 1.4.x or earlier then there is only a single important change for Steam Workshop support that will require your attention:

Paths to scripts and images can no longer use a hard-coded mod directory name.
This change is great news for players as changing the mod directory name no longer breaks mods.

To change your existing mods, just follow these instructions

JS files
GDT.loadJs uses relative paths now, so you need to change your loadJs calls from GDT.loadJs([‘./mods/myMod/myFile.js’]); to GDT.loadJs([‘myFile.js’]);

File operations
If you are loading images or files in code, then all paths need to be changed from ‘./mods/myMod/example.png’ to GDT.getRelativePath() + ‘/example.png’. (GDT.getRelativePath() returns the relative path of the calling script file).

Best Practice
GDT.getRelativePath() may not return a correct value if used inside a callback method or other anonymous function. It’s therefore best practice to call this method and store the returned value somewhere at the start of your mod code.

Example:

var ModName_AuthorName = {};

(function () {
	ModName_AuthorName.modPath = GDT.getRelativePath();//first, call getRelativePath() and keep the value for later use.

	var ready = function () {
	};

	var error = function () {
	};


	GDT.loadJs(['source/source.js',
	'source/OtherFile.js',
	'source/SubFolder/AnotherFile.js'
	], ready, error);
})();

Compatibility with non-steam version

These changes are compatible with the non-steam version, once 1.5.x is released. You will not have to maintain separate mods for steam workshop and the non-steam mods.

5 Likes

Question: If I have the JS file in a folder, will I have to make the path like this? where . is the main mod folder where package.json is included.
GDT.loadJs([‘./folder/myFile.js’]); (myFile.js loads topics, researches etc)

correct, though you don’t need to specify the dot. Just GDT.loadJS(['/folder/myFile.js']); should also work.

1 Like

Simple reply, what I needed. Same goes for images?

What does foo.bar mean here?

It’s just a placeholder name and stands for any file you want to load. EDIT: Removed the use of it as it isn’t really serving much purpose.

So I can do this, for example?
I suppose yes.

GDT.getRelativePath() + ‘/folder/example.png’

1 Like

Yes, just be aware that GDT.getRelativePath() will return the full path up to the file that called the method. Probably best tested, once you have access.

1 Like

Just got access! Many thanks!

1 Like

I updated the loadJS, but I need to do a revision here.

// Advanced Gameling
var iconAG = './mods/ExtendedGDT/images/platforms/advGameling.png';
        GDT.addPlatform({
            id : 'exGDT_advancedgameling',
            name : 'Advanced Gameling',
            company : 'Ninvento',
            startAmount : 1.1,
            unitsSold : 1.7,
            licencePrize : 90000,
            published : '14/9/4',
            platformRetireDate : '20/9/2',
            developmentCosts : 50000,
            genreWeightings : [0.8, 0.9, 1, 0.7, 0.9, 1],
            audienceWeightings : [1, 0.9, 0.7],
            techLevel : 3,
            iconUri : iconAG,
            events : [{
                id : 'exGDT_advancedgamelingrelease',
                date : '14/7/4',
                getNotification : function (company) {
                    return new Notification({
                        header : "Industry News".localize(),
                        text : "Just after getting Gameling out of the Market, Ninvento said that they are publishing their next handheld console named Gameling Advanced.{n} They say that it is an update to the original Gameling, but with better graphics and gameplay. It will be released {0}.".localize().format(General.getETADescription('14/7/4', '14/9/4')),
                        image : iconAG
                });
            }
        }
    ]
});

Will iconAG be var iconAG = GDT.getRelativePath() + ‘/images/platforms/advGameling.png’

Making sure because I don’t want to upload corrupted mods in the Workshop.

yes, this should work.
Please consider using the ‘code block’ feature in our forum software. This makes reading code much easier.

How is that used? Nobody has told me

Select your code and then press this button:

Thanks.

Another question. What about this?

image: ["./mods/ExtendedGDT/images/notifications/pixelware.png"]

The image is inside [ and ]. Will it be

image: GDT.getRelativePath() + ["/images/notifications/pixelware.png"]

This should be the last question.
Once again, making sure.

no. the [,] indicate an array of strings (which are links to images). You want to keep the string inside of the brackets, like this:

image: [GDT.getRelativePath() + "/images/notifications/pixelware.png"]

1 Like

Thanks. Almost done updating and my mod will be in the steam workshop for feedback.

2 Likes

@PatrickKlug I believe i’ve done everything correctly, but my mod doesn’t appear in the mod menu?

EDIT: I’ve fixed it, the issue was the files were inside another folder, how would i fix this for other people?

Re-upload it maybe?

Tried, still get the same issue.
How did you do it??

OPPOSMain.js has an error in line 8, it says. lemme check your mod.