Difference between revisions of "SetLang (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{| class="wikitable" style="width:100%"
+
{| 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("spk", "txt") || Definition || AFRLme
+
| setLang("txt", "vox") || Definition || AFRLme
 
|}
 
|}
  
This small function allows you to quickly set the spoken language & subtitle language. ''This function is only valid from Visionaire Studio 4.0 beta onwards''.
+
This small function allows you to quickly set the text & voice output languages.
  
 
== Instructions ==
 
== Instructions ==
 
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
 
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
2. You should edit the txtLang table to reflect your available in game languages. ''Names are case sensitive''.
+
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("en", "de") -- set spoken language to English & subtitle language to German
+
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(spk, txt)
+
function setLang(txt, vox)
  game:setValue( VGameStandardLanguage, getObject("Languages[" .. txtLang[txt] .. "]") )
+
if vox == nil then vox = txt end -- fallback in case vox equals nil
  game:setValue( VGameSpeechLanguage, getObject("Languages[" .. txtLang[spk] .. "]") )
+
-- + --
 +
  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="wikitable" style="width:100%"
+
{| class="ts" style="width:100%"
 
|-
 
|-
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:70%" | Description
+
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description
 
|-
 
|-
| spk || "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.
+
| 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.
 
|-
 
|-
| txt || "string" || This should be a "string" value containing the 2 letter prefix you added to the txtLang table of the subtitle 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.