MV Creating custom lights with Khas Advanced Lighting plugin?

So I should probably start by saying I have a very limited understanding of JavaScript. I'm currently using this plugin https://arcthunder.blogspot.com/p/tutorial-advanced-lighting.html to achieve a flashlight in the dark effect and so far it works great but I would like to insert my own image for a light.

I first inserted my image in the appropriate folder and tried to call it with the plugin command only to run into the error shown below. Upon investigating further I found I had to actually edit the plugin and so I attempted to do this, it seemed self-explanatory enough.

So after doing this (code shown below) I found I no longer ran into that error upon boot up but the image simply would not display on the screen at all. I initially did not adjust any of the positioning and I realize because of this it may have been a bit funky but considering my image size is 144 x 144 and the default image size is 120 x 191 I can't imagine it would be THAT far off.

I'd just like to know if anyone can point out what I'm doing wrong here... thanks in advance!

Bitlight.png
KhasLighting.png
Any time you're experiencing a problem with a plugin not working, press F8 during the game and go to the Console tab - see if there are any errors.

Aside from that, it would help if you posted the image you're trying to use.
Any time you're experiencing a problem with a plugin not working, press F8 during the game and go to the Console tab - see if there are any errors.

Aside from that, it would help if you posted the image you're trying to use.
I was not aware of that, I'll give that a try. This is the image I'm trying to use though, just a pixelated
flashlight sort of shape.
BitLight.png
There is no comma after intensity in the flashlight and bitlight JSON objects.
This seems to be a problem with the templates provided in the original plugin (they didn't need to work as they were provided in comments, so they probably weren't tested).
For a JSON object to be correct every property needs to be separated with a comma, event if they're on separate lines.

Just add the comma in your bitlight object and see if it helps.

flashlight: {
fileName: "flashlight",
intensity: 100 <-- missing comma here
variation: 0,
offset_x: {2: -12, 4: -72, 6: 72, 8: 16 }, // A Javascript object containing the x offset for each direction.
offset_y: {2: 72, 4: 0, 6: 16, 8: -72 }, // A Javascript object containing the y offset for each direction.
syncWithDirection: true // If you want the light's rotation to sync with the character's, use this as true.
},

When weird errors like that happen it's always a good idea to double check for typos and such, they can really mess things up and they often cause cryptic error messages 🙂
That's a good catch, @I_LIKE_BREAD7. The weird thing is the OP said the flashlight worked.
That's a good catch, @I_LIKE_BREAD7. The weird thing is the OP said the flashlight worked.
It probably worked because they used a light built into the plugin, not a custom defined one from a faulty template.
There is no comma after intensity in the flashlight and bitlight JSON objects.
This seems to be a problem with the templates provided in the original plugin (they didn't need to work as they were provided in comments, so they probably weren't tested).
For a JSON object to be correct every property needs to be separated with a comma, event if they're on separate lines.

Just add the comma in your bitlight object and see if it helps.

flashlight: {
fileName: "flashlight",
intensity: 100 <-- missing comma here
variation: 0,
offset_x: {2: -12, 4: -72, 6: 72, 8: 16 }, // A Javascript object containing the x offset for each direction.
offset_y: {2: 72, 4: 0, 6: 16, 8: -72 }, // A Javascript object containing the y offset for each direction.
syncWithDirection: true // If you want the light's rotation to sync with the character's, use this as true.
},

When weird errors like that happen it's always a good idea to double check for typos and such, they can really mess things up and they often cause cryptic error messages 🙂
It was a good catch! Unfortunately it doesn't seem to have changed anything... the error still doesn't pop up but I still can't see any sign of the light graphic either
Maybe you could try replacing the filename in the flashlight object to BitLight and see if it works that way?
This at least would tell you if the problem is in the custom definition of the light in code or in the image file itself. Given that the flashlight works, its definition must be working too.

JavaScript:
    flashlight: {
        fileName: "BitLight",
        intensity: 100, variation: 0,
        offset_x: {2: -12, 4: -72, 6: 72, 8: 16 }, offset_y: {2: 72, 4: 0, 6: 16, 8: -72 },
        syncWithDirection: true
    },

Also are you sure there are no errors in the console? (F8 -> Console tab as ATT_Turan said)
Errors in the console don't necessarily show up on the game's screen, so there might still be some even if the game starts up without going into an error screen.
Maybe you could try replacing the filename in the flashlight object to BitLight and see if it works that way?
This at least would tell you if the problem is in the custom definition of the light in code or in the image file itself. Given that the flashlight works, its definition must be working too.

JavaScript:
    flashlight: {
        fileName: "BitLight",
        intensity: 100, variation: 0,
        offset_x: {2: -12, 4: -72, 6: 72, 8: 16 }, offset_y: {2: 72, 4: 0, 6: 16, 8: -72 },
        syncWithDirection: true
    },

Also are you sure there are no errors in the console? (F8 -> Console tab as ATT_Turan said)
Errors in the console don't necessarily show up on the game's screen, so there might still be some even if the game starts up without going into an error screen.
Right, my mistake. I can't believe I never knew about checking that but I just did and actually did find something that looks relevant though I'm not exactly sure what it means.

There seems to be some sort of issue with reading the line shown below?

Edit: I also changed the original flashlight to the "BitLight" image and again nothing appeared when I called the flashlight. Then upon editing it back the exact way it was the original flashlight image wouldn't appear either

Error.png
Error2.png
Ok, now it makes sense 🙂

As I can see you edited the name of the plugin file to KhasAdvancedLightingEdit.js and that is what's causing the issue.

RPG Maker assigns parameters to plugins based on their filename, so when the plugin tries to read its parameters in the line above (359) it gets an empty object because the name doesn't match (it tries to read for KhasAdvanvedLighting instead of KhasAdvancedLightingEdit) and then tries to call a function on a non-existing object a line later which crashes it.

The fix would be to either revert the filename back to KhasAdvancedLighting.js or update the line 359 to
JavaScript:
Khas.Lighting.PARAMETERS = PluginManager.parameters("KhasAdvancedLightingEdit");
Ok, now it makes sense 🙂

As I can see you edited the name of the plugin file to KhasAdvancedLightingEdit.js and that is what's causing the issue.

RPG Maker assigns parameters to plugins based on their filename, so when the plugin tries to read its parameters in the line above (359) it gets an empty object because the name doesn't match (it tries to read for KhasAdvanvedLighting instead of KhasAdvancedLightingEdit) and then tries to call a function on a non-existing object a line later which crashes it.

The fix would be to either revert the filename back to KhasAdvancedLighting.js or update the line 359 to
JavaScript:
Khas.Lighting.PARAMETERS = PluginManager.parameters("KhasAdvancedLightingEdit");
Wow... that was it, works perfectly now! Thank you kind sir! This is why I don't do a lot of working with scripts lol it's sooo sensitive.
This is why I don't do a lot of working with scripts lol it's sooo sensitive.
It's not specific to plugins (MV doesn't use scripts).

All files you use in RPG Maker are name-sensitive. You need to make all references to file names have the correct spelling and capitalization; you need to know how the prefixes for character sheets work if you add any of those; you need to make sure you don't use URL-incompatible characters in any of your file names.

And yes, you should never rename plugins from the file name their author specified.

Original thread: https://forums.rpgmakerweb.com/threads/creating-custom-lights-with-khas-advanced-lighting-plugin.173051/