Anonymous

Module:GameData/doc: Difference between revisions

From Melvor Idle
Update JS - Support localization overrides
(Update JS)
(Update JS - Support localization overrides)
Line 15: Line 15:
this.debugMode = false;
this.debugMode = false;
this.prettyPrint = false;
this.prettyPrint = false;
this.baseDir = '/assets/data/';
this.customLocalizations = {
// Contains custom localization strings, to override any game provided localizations.
// To be used sparingly, for instances where 2+ objects of the same type
// (e.g. monsters) have the same name, as this isn't convenient to deal with in Lua
MAGIC_ABYSSAL_NAME_Madness: 'Madness (ItA)' // TotH curse also named 'Madness'
};
this.namespaces = {
this.namespaces = {
melvorD: {
melvorD: {
Line 93: Line 98:
}
}
getDataPackURL(nsID) {
getDataPackURL(nsID) {
return 'https://' + location.hostname + this.baseDir + this.namespaces[nsID].packFile + '?' + DATA_VERSION.toString();
return 'https://' + location.hostname + '/assets/data/' + this.namespaces[nsID].packFile + '?' + DATA_VERSION.toString();
}
}
async getWikiData() {
async getWikiData() {
Line 416: Line 421:
let categoryData = packData[categoryName];
let categoryData = packData[categoryName];
// Some data is adjusted before combining - do this here
// Some data is adjusted before combining - do this here
if (['combatAreas', 'dungeons', 'slayerAreas', 'abyssDepths'].includes(categoryName)) {
if (['combatAreas', 'dungeons', 'slayerAreas', 'abyssDepths', 'strongholds'].includes(categoryName)) {
// Add area type to each area object
// Add area type to each area object
const areaTypes = {
const areaTypes = {
Line 422: Line 427:
dungeons: 'dungeon',
dungeons: 'dungeon',
slayerAreas: 'slayerArea',
slayerAreas: 'slayerArea',
strongholds: 'stronghold',
abyssDepths: 'abyssDepth',
abyssDepths: 'abyssDepth',
};
};
Line 1,194: Line 1,200:
const spell = game.attackSpells.getObjectByID(data.id);
const spell = game.attackSpells.getObjectByID(data.id);
if (spell !== undefined) {
if (spell !== undefined) {
return spell.name;
return this.getLangString(`${ spell.spellbook.spellNameLangPrefix }${ spell.localID }`);
}
}
};
};
Line 1,282: Line 1,288:
},
},
strongholds: {
strongholds: {
name: { key: 'STRONGHOLD_NAME', idFormat: 'NAME_{ID}' },
name: { idFormat: 'STRONGHOLD_NAME_{ID}' },
},
},
equipmentSlots: {
equipmentSlots: {
Line 1,708: Line 1,714:
lookupVal += (lookupVal.length > 0 ? '_' : '') + identifier;
lookupVal += (lookupVal.length > 0 ? '_' : '') + identifier;
}
}
return loadedLangJson[lookupVal];
return this.customLocalizations[lookupVal] ?? loadedLangJson[lookupVal];
}
}
getNamespacedID(namespace, ID) {
getNamespacedID(namespace, ID) {