(Solved)How Brightness?

AgentN107

Bringer of laughter
Member
Joined
Aug 21, 2018
Messages
24
Reaction score
3
First Language
English
Primarily Uses
RMVXA
so I am trying to add a way to change the brightness in-game from an options menu.

it is using a variable but in case you need to see the code it is the yanfly options menu

so one way I thought of doing this is using the graphics. Brightness but while it works when I adjust it, it resets when I leave the menu but I don't know if I should really be using this command for this feature. So I am hoping for a fix to this problem or a better way to change the whole brightness. Without this command

EDIT: now after taking a break from working on this I went back to the project I was testing this into work on something else and I found out I got it to work just the menus reset their brightness which in hindsight is better for the player to see what they are doing in the menu and for the in-game it stays the brightness you change it to so there is a line of code in the menu I just don't what to overwrite but other than that this is solved. Thanks for the help
 
Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
The problem does not lie within the brightness property of the Graphics module. What is causing your brightness to reset is the fact that, as written in the documentation, there are methods of the said module that change the value of the brightness property internally. The list of methods is the following:
  • fadein;
  • fadeout;
  • transition
Unless you overwrite those methods with your own methods, there is no way that you can keep the value you previously set.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
It is a viable option, but tint screen does not work on pictures, and thus it cannot be used everywhere. However, if there are no pictures around the tint screen works perfectly.
 

yamakoku

Worldbuilding Addict
Veteran
Joined
Oct 2, 2018
Messages
36
Reaction score
18
First Language
Portuguese
Primarily Uses
RMMV
so I am trying to add a way to change the brightness in-game from an options menu.

it is using a variable but in case you need to see the code it is the yanfly options menu

so one way I thought of doing this is using the graphics.brightness but while it works when I adjust it, it resets when I leave the menu but I don't know if I should really be using this command for this feature. So I am hoping for a fix to this problem or a better way to change the whole brightness. Without this command
Have you tried looking for a plugin for adjusting brightness?
If you did google that and didn't find anything, try searching for a plugin that gives more options on graphics, or in general.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Have you tried looking for a plugin
@AgentN107 just refrain from using the word "plugin" because that is a word generally used to refer to MV codes, not VX Aces, the search will likely give you a lot of MV results, making looking for the one you want more difficult. Use the word "script" instead, that way you get more RGSS-related codes.
 

AgentN107

Bringer of laughter
Member
Joined
Aug 21, 2018
Messages
24
Reaction score
3
First Language
English
Primarily Uses
RMVXA
The problem does not lie within the brightness property of the Graphics module. What is causing your brightness to reset is the fact that, as written in the documentation, there are methods of the said module that change the value of the brightness property internally. The list of methods is the following:
  • fadein;
  • fadeout;
  • transition
Unless you overwrite those methods with your own methods, there is no way that you can keep the value you previously set.
the graphics module seems to not be in the scripts so I don't know where to start with overriding.

Have you tried looking for a plugin for adjusting brightness?
If you did google that and didn't find anything, try searching for a plugin that gives more options on graphics, or in general.
I mostly get lighting scripts from those results and they don't have overall brightness settings
 
Last edited by a moderator:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
the graphics module seems to not be in the scripts
Indeed, it is not part of the editable ones. You can only find it in the documentation (F1 in your engine, then Index -> Graphics), where only a few properties and methods are documented. It is one of the hidden modules of RGSS.
You have to take advantage of the brightness property and write your own fadein and fadeout methods.
Code:
# Pseudo-code
module Graphics
  def self.new_fade_out(duration)
    @max_brightness := brightness
    @brightness_per_frame := @max_brightness / duration
    while brightness > 0
      new_value := brightness - @brightness_per_frame
      brightness := [new_value, 0].max
      wait # just one frame is enough
    end
  end
  def self.new_fade_in(duration)
    while (brightness < @max_brightness)
      new_value := brightness + @brightness_per_frame
      brightness := [@max_brightness, new_value].min
      wait # one frame is enough
    end
  end
end
The example is just pseudo-code. I tried to stick to ruby syntax as much as possible, but in the end it is still pseudo-code and it is not going to work if you use that as it is. It is just a way to show you the basic algorithm. To polish it you would have to create a class inside the graphic module to redirect the normal fadein and fadeout methods to the new ones (I would alias the old ones so that you can still use them if you need them).

There are various reason why I did not provide the complete code:
  1. I am not sure about how the wait method is called in the Graphics module, it should be wait, but I am not completely sure and I cannot access the engine to check it right now so I think that pseudo-code works better than providing potential misleading information;
  2. This is the Learning Ruby and RGSS board, so I guess you are posting here to learn how it works, and not to have other people send you something they already wrote.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
[dpost]AgentN107[/dpost]
I have merged them for you this time. If you want to quote more than one person, please use the Multiquote button, otherwise the forum software automatically creates a new post for each quote.
Thanks.
 

AgentN107

Bringer of laughter
Member
Joined
Aug 21, 2018
Messages
24
Reaction score
3
First Language
English
Primarily Uses
RMVXA
[dpost]AgentN107[/dpost]
I have merged them for you this time. If you want to quote more than one person, please use the Multiquote button, otherwise the forum software automatically creates a new post for each quote.
Thanks.
sorry about that I responded to them at different times. Will make sure not to do that again

Indeed, it is not part of the editable ones. You can only find it in the documentation (F1 in your engine, then Index -> Graphics), where only a few properties and methods are documented. It is one of the hidden modules of RGSS.
You have to take advantage of the brightness property and write your own fadein and fadeout methods.
Code:
# Pseudo-code
module Graphics
  def self.new_fade_out(duration)
    @max_brightness := brightness
    @brightness_per_frame := @max_brightness / duration
    while brightness > 0
      new_value := brightness - @brightness_per_frame
      brightness := [new_value, 0].max
      wait # just one frame is enough
    end
  end
  def self.new_fade_in(duration)
    while (brightness < @max_brightness)
      new_value := brightness + @brightness_per_frame
      brightness := [@max_brightness, new_value].min
      wait # one frame is enough
    end
  end
end
The example is just pseudo-code. I tried to stick to ruby syntax as much as possible, but in the end it is still pseudo-code and it is not going to work if you use that as it is. It is just a way to show you the basic algorithm. To polish it you would have to create a class inside the graphic module to redirect the normal fadein and fadeout methods to the new ones (I would alias the old ones so that you can still use them if you need them).

There are various reason why I did not provide the complete code:
  1. I am not sure about how the wait method is called in the Graphics module, it should be wait, but I am not completely sure and I cannot access the engine to check it right now so I think that pseudo-code works better than providing potential misleading information;
  2. This is the Learning Ruby and RGSS board, so I guess you are posting here to learn how it works, and not to have other people send you something they already wrote.
I appreciate letting me learn and for the most part I have figured what needed to be changed. It well "works" everything becomes black. This is how it is so far
Code:
# Pseudo-code2
module Graphics
  def self.new_fade_out(duration)
    @max_brightness = brightness
    @brightness_per_frame = @max_brightness / duration
    while brightness > 0
      new_value = brightness - @brightness_per_frame
      brightness = [new_value, 0].max
      wait(1)
    end
  end
  def self.new_fade_in(duration)
    while (brightness < @max_brightness)
      new_value = brightness + @brightness_per_frame
      brightness = [@max_brightness, new_value].min
      wait(1)
    end
  end
end
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

"You can thank my later", "But you haven't done anything", "Well, that's why ..."
Are we allowed to post about non-RPG Maker games?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

Forum statistics

Threads
105,884
Messages
1,017,242
Members
137,609
Latest member
shododdydoddy
Top