MZ [MZ & MV v1.9.7] Shora Lighting & Shadow System

best way is for a conditional branch,
if switch A is ON / or if button X is pressed
turn torch ON
else
turn torch OFF
end

that is the most basic settings, so why 2 common events?
I've did it differently, i've create a new torchlight and specify change is X and Y from the menu.

Now i've another issu, but im pretty sure its my fault.
I want to make an On/off torchlight, so ive create 2 common even from the data base.
One said something like :
If you press A, add torch item on inventory (item with have [light]) then trigger ''torch on'' variable to 1

This part work as intended


And in the 2nd common even, i mirror it like :
If you press A, and of variable torch is on 1, then delete the torch from inventory and put ''torch on'' variable to 0


Annnd it dont really work.

One time i''ve almsot success but i had to let A hold, and i just want a Switch, not an holding button.
It was because this attempt have ''else'' condition and it trigger the light every frame i suppose.

Help 😀
I have something similar. This is what I use for my player's torch (the lighting that shows up around the character). I'm using Yanfly's Button Common Event plugin. So, when players press T on their keyboard, the light turns on/off. I have my common event set up the following way:

I have a switch called "Lighting On/Off." You could also use SelfSwitches. I use a normal switch because I have events in my game that will react to whether your torch is on or off, though. But basically...

Spoiler: Example
1667490888155.png

As you can see... if the light is off, the else branch plays turning it on (adding the item) and turning that switch ON. Then if you press the button again... it'll read the switch being on and play that top part (turning it "off"). Not sure if this helps with what you're going for, though.
best way is for a conditional branch,
if switch A is ON / or if button X is pressed
turn torch ON
else
turn torch OFF
end

that is the most basic settings, so why 2 common events?
that's why i've try at first, and the problem is my light stay only few second (like 1 or 2sec if im lucky)
If i hold the button, it work, but i want a switch, i want to press once the key and the light stay ON, press the key again and the light go OFF
And this is what i dont understand in my event, it's supposed to do it, no ?

1667519753878.png


Sorry, it's in french, but im sure its understandable.

@AeroFunk80 i dont have this plugin, i cant do it without it ?
that's why i've try at first, and the problem is my light stay only few second (like 1 or 2sec if im lucky)
If i hold the button, it work, but i want a switch, i want to press once the key and the light stay ON, press the key again and the light go OFF
And this is what i dont understand in my event, it's supposed to do it, no ?

View attachment 244370

Sorry, it's in french, but im sure its understandable.

@AeroFunk80 i dont have this plugin, i cant do it without it ?
Oh, yes, you'd need a plugin for what I suggested. Sorry. I would recommend it (not that you have to). You can actually get that plus 40+ more for just $10 on Itch.

I believe you can still do it without the plugin, but you wouldn't be able to use any button in your common event. RM MV only allows you to set a condition for certain keys (space, enter, etc). Also... since I don't understand the language...

I know 'Declencheur' is the trigger "Parallel." Your switch is one thing and the conditional branch is another. What conditional branch are you using? And what key are you assigning to activate the flashlight/torch?
1667564540321.png


I use "page down" as key, its the basic one from RPG maker, i didnt change any key for the moment
double check the demo where the flashlight is given,
it might give you the answer you miss, and you can turn off
and on the flashlight if the player has the item, so not sure
why you "add item +1" as this normally doesn't show the light
I believe.
View attachment 244391

I use "page down" as key, its the basic one from RPG maker, i didnt change any key for the moment
I tried a couple things and couldn't figure out/get it to work using a parallel common event. Problem with having a parallel event always running to turn a torch on/off is that... it's always running, plus pressing the button once causes a weird glitch.

I'm not sure if it's within your budget, but I'd highly recommend getting Yanfly's Button Common Event. It'll make what you're trying to achieve so much easier, and I can share what I did for mine with you, as well.

If you're looking for a way to do this without getting any plugins, I'd recommend posting your question in The Legacy Engine Support forum and then the MV section. I'm sure someone in there may have a solution/suggestion for what you're trying to do without a plugin. You could start there. More people will be able to help if you ask your specific question in that section. Posting it in here just has it buried, so only myself and Shadow have noticed it. Someone else might be able to help by posting in the support channel.
double check the demo where the flashlight is given,
it might give you the answer you miss, and you can turn off
and on the flashlight if the player has the item, so not sure
why you "add item +1" as this normally doesn't show the light
I believe.

The demo is basically what ive done, it add "flashlight+1" in inventory, and stay ON until you talk again to the npc who put flashlight-1 off inventory :/

I guess i've to try these plugin tho, i'll come back with more news when it work 😀
in the demo when checked, the npc " is giving him" the flashlight,
which is differently when you "obtained" a flashlight.

if you gain the item, and turn it off with -1, you cannot acces the flashlight
to turn it on if it is used 🙂

so enable and diable light is differently.

I will check the plugin as I think you can enable light sourch "flashlight"
to ON and OFF, as you can turn off the entire plugin on and off as well.
event light easely with selfswitch ON/OF or by global if you turn off everything.

as you create a struct with custom lights, you can probably control each light
the same, but you also need to remember if you make duplicates of the flashlight
or is used that those are also goes OFF, so you can probably make "pFlashLight"
for the player item, but the same effect as "flashlight" if used by multiple events.
The demo is basically what ive done, it add "flashlight+1" in inventory, and stay ON until you talk again to the npc who put flashlight-1 off inventory :/

I guess i've to try these plugin tho, i'll come back with more news when it work 😀
Let me know if you get the button common event plugin. If you need help mapping out your torch/flashlight even there, I can send you what I've done.
I'm back !

So i've found the Visustella button common event (the same than Yanfly, but for MZ)
And it work like exactly like you say, i can turn on/off the light with the shotcut i want.

Thank you
I'm back !

So i've found the Visustella button common event (the same than Yanfly, but for MZ)
And it work like exactly like you say, i can turn on/off the light with the shotcut i want.

Thank you
Oh, I'm sorry. Not sure why I thought you were using MV. Glad to hear that, plus you have more options regarding which keyboard key you want to use, too.
1668556868761.png

Hi all, was wondering how to get the light to not go on top of the player here? thanks
View attachment 245247
Hi all, was wondering how to get the light to not go on top of the player here? thanks
I'm pretty sure we can't, because the light work as picture i guess.
even if you could, it will be also below the enemy and other tiles which are on normal.
so it could be doable, but it require some js knowledge as it wont be to for the actor
alone or set the z-index higher.

I dont think it would be worth the trouble though.
I'm migrating from Community Lighting. I can't find a way in this plugin to attach light to entire region ID. Is there something I'm missing, or is that feature not supported?
I believe I have gotten region-based lighting working with one big caveat: I had to turn off shadows for all region-based light, because it was displaying wonky and I couldn't for the life of me figure out how to correct it (it is something to do with the displayX and displayY upon entering a map affecting how the shadow geometry gets applied to the light).

So, first, I re-enabled all of the static light code in the plugin. I also had to modify LightingLayer.addStaticLight a bit, because I wanted to pass in tile coords rather than screen coords:

JavaScript:
addStaticLight(options) {
    const tileWidth = $gameMap.tileWidth();
    const tileHeight = $gameMap.tileHeight();
    const displayX = $gameMap.displayX();
    const displayY = $gameMap.displayY();

    options.x = (options.x * tileWidth) + (tileWidth / 2) + displayX;
    options.y = (options.y * tileHeight) + (tileHeight / 2) + displayY;
    options.shadow = false;

    const light = new LightingSprite(options);
    light.renderable = true;

    light.texture.baseTexture.premultipliedAlpha = false;

    if (Shora.EngineVersion === 'MV') {
        light.blendMode = PIXI.BLEND_MODES.NORMAL; // TODO
    }

    Graphics.app.renderer.render(light, this._staticLighting, this._clearStaticLayer);
    this._clearStaticLayer = false;

    // lights will get automatically destroyed by texture collector
    light.destroy();
}

After that, it was a simple matter of making my own plugin to walk a map searching for a particular region ID and add static light to all matching tiles:

JavaScript:
PluginManager.registerCommand("RegionLighting", "activate", args => {
    const regionId = Number(args.regionId);
    const lightRef = String(args.lightRef);

    const mapWidth = $gameMap.width();
    const mapHeight = $gameMap.height();

    for (let x = 0; x < mapWidth; x++) {
        for (let y = 0; y < mapHeight; y++) {
            if ($gameMap.regionId(x, y) === regionId) {
                $gameLighting.addStaticLight(x, y, lightRef);
            }
        }
    }
});

This seems to work correctly. It's a bummer that I can't get shadows against this light, but since I'm using this for more of ambient glow on certain tiles, it's not the end of the world. It certainly beats having to switch everything back to Community Lighting to get this feature.

It would be great to get a plugin update that adds static light properly with shadows enabled!
Shora,
I can't seem to get shadows to update after I have changed the region ID in game with events. Is this plugin set to re evaluate shadows after there has been region ID changes in game? I have tested it on my end by adding lights that turn on when the region ID changes. The lights turn on, but the shadow still stays.
@Ninja777 how do you change region ID? if you stay on the same map
and does work after you change maps, you can use a map update request,
as I use it on my main project in a mechanic, so I think it should work the
with region based on the same map.
@Ninja777 how do you change region ID? if you stay on the same map
and does work after you change maps, you can use a map update request,
as I use it on my main project in a mechanic, so I think it should work the
with region based on the same map.
I had that thought, so I added in a map transfer or a map update using
$gameMap.refresh()
The only thing that works is saving and closing or a complete map change then return.

Original thread: https://forums.rpgmakerweb.com/threads/mz-mv-v1-9-7-shora-lighting-shadow-system.131410/