LangVisibility (CMS)

From The Official Visionaire Studio: Adventure Game Engine Wiki
Revision as of 23:24, 23 August 2022 by AFRLme (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Name Type By
langVisibility(duration, easing) Definition AFRLme

This small function allows you to quickly adjust the visibility of all scene objects containing language names in them.


Quick note: this function is slow & should only be called at begin of scene if the scene is faded in & not shown immediately; other than that feel free to use it however you like.


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 visibility of all objects containing active language name to 100%; set objects with other language names to 0%.

langVisibility()

2b. Usage example #2: update visibility over 1000ms for all objects containing active language name to 100%; set objects with other language names to 0%.

langVisibility(1000)


Main Script

local obj = {} -- init obj table

function langVisibility(duration, easing)
  duration = duration or 0 -- fallback in case duration equals nil
  easing = easing or easeLinearInOut -- fallback in case duration equals nil
  obj = game.CurrentScene.Objects -- store current scene objects
  -- + --
  for i = 1, #obj do -- iterate through the current scene objects table
    for a = 1, #game.Languages do -- iterate through language tables
      if string.find( string.lower( obj[i]:getName() ), string.lower( game.Languages[a]:getName() ) ) then -- language found
        if game.StandardLanguage == game.Languages[a] then -- language is current language
          obj[i]:to(duration, {Visibility = 100}, easing) -- set visibility of currently listed scene object to 100%
        else -- language is not current language
          obj[i]:to(duration, {Visibility = 0}, easing) -- set visibility of currently listed scene object to 0%
        end
      end
    end
  end
end


Syntax Breakdown

Name Type Description
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.