[SOLVED] Khas Ultra lighting module : free some numbers in the R tileset

Hello RPG Makers,

so I'm having fun with plugins last few weeks on RPG Maker MV 1.5.1, and I stumbled on the Khas Ultra Lighting plugin, which looks amazing. (quick link to his work here : http://arcthunder.blogspot.ca/p/rpg-maker-mv-plugins.html )

So the lighting plugin uses the R tileset numbers to tag walls and their height. To do so, it takes the number used, divide it by 10, and assume it's the wall height. I think the idea is interesting, but here comes my problem :

The plugin also consider that any number used is eligible for the above process, as it round down the result after dividing by 10. So every number from 10 to 19 does the same thing, resulting in a wall height tagging of 1. The thing is, such system takes 246 tiles of 255, only letting the 9 first numbers to use for other purposes.

Some screenshots to illustrate :

I want a hiding area with the tag 13 using Yanfly script :

upload_2018-5-11_18-18-3.png


But the light system is breaking :

upload_2018-5-11_18-17-21.png


So here is my question : is there a way to fix this ?
I am pretty sure I won't have walls higher than 9 tiles...

I made some digging by myself, and found this function :

Spoiler: Code piece
Game_Map.prototype.genHeightMap = function() {
this._heightMap = [];
for (var x = 0; x < this.width(); x++) {
this._heightMap.push([]);
for (var y = 0; y < this.height(); y++) {
var h = Math.floor(this.regionId(x, y) / 10) * 2;
this._heightMap[x].push(h);
};
};
for (var x = 0; x < this.width(); x++) {
for (var y = 0; y < this.height(); y++) {
var h = this._heightMap[x][y];
var nh = this.getHeight(x, y + 1);
if (h > 0 && this.isFloor(x, y) && h > nh) {
h -= 1;
var dy = 1;
while (h > 0 && (nh == 0 || h - 1 > nh) && this.isValid(x, y + dy)) {
this.setHeight(x, y + dy, h);
h -= 2;
dy += 1;
if (this.isValid(x, y + dy)) nh = this.getHeight(x, y + dy);
};
};
};
};
};

As far as I understand, there could be 2 ways to solve the problem :

1 - Making any number which is not a multiple of 10 considered as 0, or ignored by the script
2 - Getting rid off the "divide by 10" portion, only tagging tiles from 1 to 9. But it would also mean to make the script ignore numbers higher than 9.

My Javascript knowledge is sadly very limited, so that's why I'm posting here, searching clues, better ways to achieve my goal, or even learn how to efficiently modify the code to fit my needs.

Thanks for your attention, I hope I will read your answers soon 😉

PS : Sorry if my english is a little clunky
So I struggled a lot with that (mainly for stupid mistakes...) but I think I managed to modify it correctly.
I am however very unsure about his terms about reposting an edited version of his script... http://arcthunder.blogspot.ca/p/terms-of-use.html
I don't want any credit, it's not my work after all, I just altered a very little portion of his code to fit my needs (and as I found by looking for an answer, I was not the only one)
Can someone clarify for me if I can post this edited version (a version allowing to choose how much tiles the script uses for the light mapping) ?
If it can help other people, I would love to do so !

Original thread: https://forums.rpgmakerweb.com/threads/solved-khas-ultra-lighting-module-free-some-numbers-in-the-r-tileset.95164/