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.
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)
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.
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.