porymap/test_script.js

27 lines
833 B
JavaScript
Raw Normal View History

2020-05-03 16:00:56 +01:00
const nightTint = [0.6, 0.55, 1.0];
function applyTint(palette, tint) {
for (let i = 0; i < palette.length; i++) {
const color = palette[i];
for (let j = 0; j < tint.length; j++) {
color[j] = Math.floor(color[j] * tint[j]);
}
}
}
// Porymap callback when a map is opened.
export function on_map_opened(mapName) {
2020-05-03 16:00:56 +01:00
try {
for (let i = 0; i < 13; i++) {
const primaryPalette = map.getPrimaryTilesetPalette(i)
applyTint(primaryPalette, nightTint)
map.setPrimaryTilesetPalette(i, primaryPalette)
const secondaryPalette = map.getSecondaryTilesetPalette(i)
applyTint(secondaryPalette, nightTint)
map.setSecondaryTilesetPalette(i, secondaryPalette)
}
} catch (err) {
console.log(err)
}
}