Difference between revisions of "SetLang (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {| class=" | + | {| 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 | ||
|- | |- | ||
− | | setLang(" | + | | setLang("txt", "vox") || Definition || AFRLme |
|} | |} | ||
− | 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 12: | Line 12: | ||
2. You should edit the '''txtLang''' table to reflect your available in game languages. ''Names are case sensitive''.<br/> | 2. You should edit the '''txtLang''' table to reflect your available in game languages. ''Names are case sensitive''.<br/> | ||
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 lang="lua"> |
− | setLang(" | + | setLang("de", "en") -- set text language to German & spoken language to English |
</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> | ||
== Syntax Breakdown == | == Syntax Breakdown == | ||
− | {| class=" | + | {| class="ts" style="width:100%" |
|- | |- | ||
− | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width: | + | ! 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}} |
Latest revision as of 22:54, 20 August 2022
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. |