Difference between revisions of "ObjVisibility (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "{| class="ts" style="width:100%" |- ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By |- | onjVisibility({t}, val, duration, e...") |
m |
||
(6 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
! 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 | ||
|- | |- | ||
− | | | + | | objVisibility({t}, val, duration, easing) || Definition || AFRLme |
|} | |} | ||
Line 15: | Line 15: | ||
objVisibility({"obj1", "obj2", "obj3"}, 0) | objVisibility({"obj1", "obj2", "obj3"}, 0) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | 2b. Usage example # | + | 2b. Usage example #2: update the visibility of all listed scene objects in the linked table to 50% over 250ms with easeQuadOut easing |
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local tbl = {"obj1", "obj2", "obj3"} | local tbl = {"obj1", "obj2", "obj3"} | ||
− | objVisibility( | + | objVisibility(tbl, 50, 250, easeQuadOut) |
</syntaxhighlight> | </syntaxhighlight> | ||
Line 27: | Line 27: | ||
function objVisibility(t, val, duration, easing) | function objVisibility(t, val, duration, easing) | ||
duration = duration or 0 -- fallback in case duration equals nil or empty | duration = duration or 0 -- fallback in case duration equals nil or empty | ||
− | easing = easing or easeLinearInOut -- fallback in case | + | easing = easing or easeLinearInOut -- fallback in case easing equals nil |
-- + -- | -- + -- | ||
for i = 1, #t do -- iterate through the tables | for i = 1, #t do -- iterate through the tables | ||
Line 45: | Line 45: | ||
| val || integer || This should contain a number value between 0 & 100, with zero being invisible & 100 being fully visible. | | val || integer || This should contain a number value between 0 & 100, with zero being invisible & 100 being fully visible. | ||
|- | |- | ||
− | | duration || integer || This should contain a number value in milliseconds of how long you want the visibility to change from the current value to the target value | + | | duration || integer || This should contain a number value in milliseconds of how long you want the visibility to take to change from the current value to the target value. |
|- | |- | ||
− | | easing || integer || This should contain a number value, or the variable name of the easing type that you want to use. Here is a list of available [https:// | + | | easing || integer || This should contain a number value, or the variable name of the easing type that you want to use. Here is a list of available [https://www.visionaire-studio.com/luadocs/lua.html#easing easing options]. |
|}{{toc}} | |}{{toc}} |
Latest revision as of 22:59, 16 November 2022
Name | Type | By |
---|---|---|
objVisibility({t}, val, duration, easing) | Definition | AFRLme |
This small function allows you to quickly adjust the visibility of multiple scene objects, which can be useful for setting up scenes without having to create tons of set visibility action parts.
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 visibility of all listed scene objects to 0
objVisibility({"obj1", "obj2", "obj3"}, 0)
2b. Usage example #2: update the visibility of all listed scene objects in the linked table to 50% over 250ms with easeQuadOut easing
local tbl = {"obj1", "obj2", "obj3"}
objVisibility(tbl, 50, 250, easeQuadOut)
Main Script
function objVisibility(t, val, duration, easing)
duration = duration or 0 -- fallback in case duration equals nil or empty
easing = easing or easeLinearInOut -- fallback in case easing equals nil
-- + --
for i = 1, #t do -- iterate through the tables
game.CurrentScene.Objects[ t[i] ]:to(duration, {Visibility = val}, easing) -- update visibility of currently listed scene object
end
end
Syntax Breakdown
Name | Type | Description |
---|---|---|
t | table | This should be a table or linked table containing the "names" of the scene objects that you want to update visibility (opacity) value of. |
val | integer | This should contain a number value between 0 & 100, with zero being invisible & 100 being fully visible. |
duration | integer | This should contain a number value in milliseconds of how long you want the visibility to take to change from the current value to the target value. |
easing | integer | This should contain a number value, or the variable name of the easing type that you want to use. Here is a list of available easing options. |