SetLang (CMS)

From The Official Visionaire Studio: Adventure Game Engine Wiki
Revision as of 22:54, 20 August 2022 by AFRLme (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Name Type By
setLang("txt", "vox") Definition AFRLme

This small function allows you to quickly set the text & voice output languages.

Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2. You should edit the txtLang table to reflect your available in game languages. Names are case sensitive.
3. To use this function you should create an execute a script action containing...

setLang("de", "en") -- set text language to German & spoken language to English

Main Script

-- * table containing the available game languages with 2 letter prefix for table names * --
local txtLang = {en = "English", de = "German", fr = "French"}

function setLang(txt, vox)
 if vox == nil then vox = txt end -- fallback in case vox equals nil
 -- + --
 game.StandardLanguage = Languages[ txtLang[txt] ] -- update text language
 game.SpeechLanguage = Languages[ txtLang[vox] ] -- update speech language
end

Syntax Breakdown

Name Type Description
txt "string" This should be a "string" value containing the 2 letter prefix you added to the txtLang table of the text language you want to set.
vox "string" This should be a "string" value containing the 2 letter prefix you added to the txtLang table of the spoken language you want to set.