Difference between revisions of "SetSceneBrightness (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {| class=" | + | {| class="ts" style="width:100%" |
|- | |- | ||
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By | ||
|- | |- | ||
− | | setSceneBrightness("scn" | + | | setSceneBrightness("scn", val, duration) || Definition || AFRLme |
|} | |} | ||
− | This small function allows you to | + | This small function quickly allows you to immediately set the brightness value of the current scene or a specific scene; or over x duration, if desired. |
+ | |||
== Instructions == | == Instructions == | ||
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/> | 1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/> | ||
− | 2a. | + | 2a. Usage Example #1: immediately update the brightness belonging to a specific scene to 80 percent. |
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
− | setSceneBrightness("scene_name", 80) | + | setSceneBrightness("scene_name", 80) |
</syntaxhighlight> | </syntaxhighlight> | ||
− | 2b. | + | 2b. Usage Example #2: immediately update the brightness belonging to the current scene to 80 percent. |
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
− | setSceneBrightness(nil, 80) | + | setSceneBrightness(nil, 80) |
</syntaxhighlight> | </syntaxhighlight> | ||
+ | 2c. Usage Example #3: update the brightness belonging to the current scene to 80 percent over 1000ms. | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | setSceneBrightness(nil, 80, 1000) | ||
+ | </syntaxhighlight> | ||
+ | |||
== Main Script == | == Main Script == | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
− | function setSceneBrightness(scn, | + | function setSceneBrightness(scn, val, duration) |
− | if scn | + | if scn == nil then scn = game.CurrentScene or scn = Scenes[scn] end -- check current scene or specific scene |
− | + | duration = duration or 0 -- fallback in case duration equals nil | |
− | + | -- + -- | |
− | + | scn:to(duration, {Brightness = val}) -- update specified scene brightness | |
− | |||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
== Syntax Breakdown == | == Syntax Breakdown == | ||
− | {| class=" | + | {| class="ts" style="width:100%" |
|- | |- | ||
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description | ||
|- | |- | ||
− | | scn || "string" | + | | scn || "string" or nil || This should be a "string" value containing the name of the scene you want to affect; or nil to link to the current scene. |
|- | |- | ||
− | | | + | | val || integer || This should be a number value which will determine the brightness value of the specifed/current scene. |
− | |} | + | |- |
+ | | duration || integer || This should contain a number value in milliseconds of how long you want the current scene brightness to take to get from the current value to the target value. | ||
+ | |}{{toc}} |
Latest revision as of 19:50, 23 August 2022
Name | Type | By |
---|---|---|
setSceneBrightness("scn", val, duration) | Definition | AFRLme |
This small function quickly allows you to immediately set the brightness value of the current scene or a specific scene; or over x duration, if desired.
Instructions
1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. Usage Example #1: immediately update the brightness belonging to a specific scene to 80 percent.
setSceneBrightness("scene_name", 80)
2b. Usage Example #2: immediately update the brightness belonging to the current scene to 80 percent.
setSceneBrightness(nil, 80)
2c. Usage Example #3: update the brightness belonging to the current scene to 80 percent over 1000ms.
setSceneBrightness(nil, 80, 1000)
Main Script
function setSceneBrightness(scn, val, duration)
if scn == nil then scn = game.CurrentScene or scn = Scenes[scn] end -- check current scene or specific scene
duration = duration or 0 -- fallback in case duration equals nil
-- + --
scn:to(duration, {Brightness = val}) -- update specified scene brightness
end
Syntax Breakdown
Name | Type | Description |
---|---|---|
scn | "string" or nil | This should be a "string" value containing the name of the scene you want to affect; or nil to link to the current scene. |
val | integer | This should be a number value which will determine the brightness value of the specifed/current scene. |
duration | integer | This should contain a number value in milliseconds of how long you want the current scene brightness to take to get from the current value to the target value. |