Screen Darken when Player Dies

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Screen Darken when Player Dies

Postby Chilly14 » Sat Oct 19, 2019 1:13 pm

Say, have you played any of the more recent Kirby and Mario 3D platformers (such as Super Mario 3D World)? Well, whenever the player dies, almost everything on the screen darkens except the player themselves. So I'd love to find a way to make it so that whenever the player dies in SMBX, almost everything on the screen darkens except the player.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9891
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Screen Darken when Player Dies

Postby Emral » Sat Oct 19, 2019 1:25 pm

Player death effect renders to priority -5, so without redrawing that manually, you will still see other foreground effects and the HUD undarkened.
https://wohlsoft.ru/pgewiki/LunaLua_Render_Priority

in onDraw:
if player.deathTimer > 0 then
Graphics.drawScreen{color = Color.black .. 0.2, priority = -6}
end

The 0.2 is the alpha channel for the color overlay.

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: Screen Darken when Player Dies

Postby Chilly14 » Sat Oct 19, 2019 2:02 pm

Enjl wrote:
Sat Oct 19, 2019 1:25 pm
Player death effect renders to priority -5, so without redrawing that manually, you will still see other foreground effects and the HUD undarkened.
https://wohlsoft.ru/pgewiki/LunaLua_Render_Priority

in onDraw:
if player.deathTimer > 0 then
Graphics.drawScreen{color = Color.black .. 0.2, priority = -6}
end

The 0.2 is the alpha channel for the color overlay.
Tried doing that, but for some reason, it still darkens the death effect. I set the effect's priority to 6.0 and the black screen's to -3.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9891
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Screen Darken when Player Dies

Postby Emral » Sat Oct 19, 2019 2:18 pm

...huh? How did you change the effect's priority? effect.txt doesn't apply to old effects. The handbook explciitly states that. I just tested my code and it works (no other code or modifications present).

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: Screen Darken when Player Dies

Postby Chilly14 » Sat Oct 19, 2019 2:36 pm

Enjl wrote:
Sat Oct 19, 2019 2:18 pm
...huh? How did you change the effect's priority? effect.txt doesn't apply to old effects. The handbook explciitly states that. I just tested my code and it works (no other code or modifications present).

Code: Select all

[1]

import=AI_PLAYER

priority=8.0
Hastebin suddenly stopped working properly so I had to paste it like this.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9891
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Screen Darken when Player Dies

Postby Emral » Sat Oct 19, 2019 2:37 pm

Chilly14 wrote:
Sat Oct 19, 2019 2:36 pm
Enjl wrote:
Sat Oct 19, 2019 2:18 pm
...huh? How did you change the effect's priority? effect.txt doesn't apply to old effects. The handbook explciitly states that. I just tested my code and it works (no other code or modifications present).

Code: Select all

[1]

import=AI_PLAYER

priority=8.0
Hastebin suddenly stopped working properly so I had to paste it like this.
Image
Enjl wrote:
Sat Oct 19, 2019 2:18 pm
effect.txt doesn't apply to old effects

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: Screen Darken when Player Dies

Postby Chilly14 » Sat Oct 19, 2019 2:39 pm

Enjl wrote:
Sat Oct 19, 2019 2:37 pm
Chilly14 wrote:
Sat Oct 19, 2019 2:36 pm
Enjl wrote:
Sat Oct 19, 2019 2:18 pm
...huh? How did you change the effect's priority? effect.txt doesn't apply to old effects. The handbook explciitly states that. I just tested my code and it works (no other code or modifications present).

Code: Select all

[1]

import=AI_PLAYER

priority=8.0
Hastebin suddenly stopped working properly so I had to paste it like this.
Image
Enjl wrote:
Sat Oct 19, 2019 2:18 pm
effect.txt doesn't apply to old effects
Well, that sucks. Can you show me your code?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9891
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Screen Darken when Player Dies

Postby Emral » Sat Oct 19, 2019 2:40 pm

Chilly14 wrote:
Sat Oct 19, 2019 2:39 pm
Well, that sucks. Can you show me your code?
Enjl wrote:
Sat Oct 19, 2019 1:25 pm
Player death effect renders to priority -5, so without redrawing that manually, you will still see other foreground effects and the HUD undarkened.
https://wohlsoft.ru/pgewiki/LunaLua_Render_Priority

in onDraw:
if player.deathTimer > 0 then
Graphics.drawScreen{color = Color.black .. 0.2, priority = -6}
end

The 0.2 is the alpha channel for the color overlay.
Like I said, I didn't have anything else going on.

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: Screen Darken when Player Dies

Postby Chilly14 » Sat Oct 19, 2019 2:42 pm

Enjl wrote:
Sat Oct 19, 2019 2:40 pm
Chilly14 wrote:
Sat Oct 19, 2019 2:39 pm
Well, that sucks. Can you show me your code?
Enjl wrote:
Sat Oct 19, 2019 1:25 pm
Player death effect renders to priority -5, so without redrawing that manually, you will still see other foreground effects and the HUD undarkened.
https://wohlsoft.ru/pgewiki/LunaLua_Render_Priority

in onDraw:
if player.deathTimer > 0 then
Graphics.drawScreen{color = Color.black .. 0.2, priority = -6}
end

The 0.2 is the alpha channel for the color overlay.
Oh.
Wait, how do I redraw the death effect's priority?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9891
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Screen Darken when Player Dies

Postby Emral » Sat Oct 19, 2019 2:44 pm

Why do you want to do that?

There's many ways to do it. I'd probably make an effect in the custom range (751-1000) and manually spawn it and make the default one invisible.

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: Screen Darken when Player Dies

Postby Chilly14 » Sat Oct 19, 2019 2:52 pm

Okay. I'll try that later.

Added in 6 hours 34 minutes 46 seconds:
Enjl wrote:
Sat Oct 19, 2019 2:44 pm
Why do you want to do that?

There's many ways to do it. I'd probably make an effect in the custom range (751-1000) and manually spawn it and make the default one invisible.
Okay, I've made an attempt to do it. However, there's still a problem. Whenver I die, it results in error spam.

Current code: https://hastebin.com/nimacoxuzu.rb
The error:
Image

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Screen Darken when Player Dies

Postby Hoeloe » Sat Oct 19, 2019 9:54 pm

You never defined what v is in this context. You're looking for "v.x", without telling the program what "v" is.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 6 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari