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="wikitable" style="width:100%"
+
{| 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" ''or'' nil, n) || Definition || AFRLme
+
| setSceneBrightness("scn", val, duration) || Definition || AFRLme
 
|}
 
|}
  
This small function allows you to quickly set the brightness value of the current scene or a specific scene.
+
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. To use this function you should create an ''execute a script'' action containing...
+
2a. Usage Example #1: immediately update the brightness belonging to a specific scene to 80 percent.
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
setSceneBrightness("scene_name", 80) -- sets the linked scenes brightness value to 80%
+
setSceneBrightness("scene_name", 80)
 
</syntaxhighlight>
 
</syntaxhighlight>
2b. Alternatively to automatically link to current scene use this method...
+
2b. Usage Example #2: immediately update the brightness belonging to the current scene to 80 percent.
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
setSceneBrightness(nil, 80) -- sets the current scenes brightness value to 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, n)
+
function setSceneBrightness(scn, val, duration)
  if scn ~= nil then
+
  if scn == nil then scn = game.CurrentScene or scn = Scenes[scn] end -- check current scene or specific scene
  getObject("Scenes[" .. scn .. "]"):setValue(VSceneBrightness, n)
+
duration = duration or 0 -- fallback in case duration equals nil
  else
+
  -- + --
  game:getLink(VGameCurrentScene):setValue(VSceneBrightness, n)
+
scn:to(duration, {Brightness = val}) -- update specified scene brightness
end
 
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
== Syntax Breakdown ==
 
== Syntax Breakdown ==
{| class="wikitable" style="width:100%"
+
{| 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" ''or'' <span class="blue">nil</span> || This should be a "string" value containing the name of the scene you want to affect else it should contain the word ''<span class="blue">nil</span>''.
+
| 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.
 
|-
 
|-
| n || integer || This should be an integer (number) value which will determine the brightness value of the linked scene (scn) or the current scene if ''<span class="blue">nil</span>'' was used.
+
| 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.