Difference between revisions of "SetLang (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m (Text replacement - "wikitable" to "ts") |
|||
Line 6: | Line 6: | ||
|} | |} | ||
− | This small function allows you to quickly set the | + | This small function allows you to quickly set the text & voice output languages. |
== Instructions == | == Instructions == | ||
Line 13: | Line 13: | ||
3. To use this function you should create an ''execute a script'' action containing... | 3. To use this function you should create an ''execute a script'' action containing... | ||
<syntaxhighlight> | <syntaxhighlight> | ||
− | setLang(" | + | setLang("de", "en") -- set spoken language to English & text language to German |
</syntaxhighlight> | </syntaxhighlight> | ||
== Main Script == | == Main Script == | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
-- * table containing the available game languages with 2 letter prefix for table names * -- | -- * table containing the available game languages with 2 letter prefix for table names * -- | ||
local txtLang = {en = "English", de = "German", fr = "French"} | local txtLang = {en = "English", de = "German", fr = "French"} | ||
− | function setLang( | + | function setLang(txt, vox) |
− | game | + | if vox == nil then vox = txt end -- fallback in case vox equals nil |
− | game | + | -- + -- |
+ | game.StandardLanguage = Languages[ txtLang[txt] ] -- update text language | ||
+ | game.SpeechLanguage = Languages[ txtLang[vox] ] -- update speech language | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 32: | Line 34: | ||
! 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 | ||
|- | |- | ||
− | | | + | | 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. |
− | |} | + | |}{{toc}} |
Revision as of 22:53, 20 August 2022
Name | Type | By |
---|---|---|
setLang("spk", "txt") | 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 spoken language to English & text language to German
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. |