Difference between revisions of "GetProperty"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<div class="toccolours mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%">
+
==getProperty==
<b>Command History</b>
 
<div class="mw-collapsible-content">
 
<div style="background:#ebebeb" width="100%">Available since <span style="color:orange">v3.7</span></div>
 
</div></div>
 
  
 +
<div class="command-min-version-info">Available since: <span class="command-min-version">v4.1</span></div>
  
Return the requested property.
+
<div class="command-doc">Return the requested property.</div>
  
 
+
Lua Syntax:
Syntax:
+
<pre class="command-syntax">getProperty(property)</pre>
 +
===Arguments===
 +
====property====
 +
:'''"string"''' - The requested property to retrieve. Currently supported properties: "platform" ("win"/"mac"),
 +
:"steam_initialized" (true/false depending if the steam_api was loaded and client is connected, false if the operation failed),
 +
:"galaxy_initialized" (true/false depending if the gog galaxy_api was loaded and client is connected, false if the operation failed),
 +
:"system_language" Returns English name of system language or "unknown" if language could not be retrieved.
 +
===Flags===
 +
===Return Values===
 +
;property
 +
:requested property value.
 +
===Examples===
 +
Example 1: "platform"
 
<syntaxhighlight>
 
<syntaxhighlight>
getProperty(property)
+
-- if platform equals windows then do some action else if mac do some other action
 +
if getProperty("platform") == "win" then
 +
  getObject("Conditions[win?]"):setValue(VConditionValue, true)
 +
elseif getProperty("platform") == "mac" then
 +
  getObject("Conditions[mac?]"):setValue(VConditionValue, true)
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
Example 2: "steam_initialized"
 +
<syntaxhighlight>
 +
-- let's check if steam has initialized & set a value based on return value
 +
local steamLoaded = getProperty("steam_initialized")
  
 +
if steamLoaded then
 +
  getObject("Conditions[steamLoaded?]"):setValue(VConditionValue, true)
 +
else
 +
  getObject("Conditions[steamLoaded?]"):setValue(VConditionValue, false)
 +
end
 +
</syntaxhighlight>
 +
Example 3: "galaxy_initialized"
 +
<syntaxhighlight>
 +
-- let's check if gog galaxy has initialized & set a value based on return value
 +
local galaxyLoaded = getProperty("galaxy_initialized")
  
Example:
+
if galaxyLoaded then
 +
  getObject("Conditions[galaxyLoaded?]"):setValue(VConditionValue, true)
 +
else
 +
  getObject("Conditions[galaxyLoaded?]"):setValue(VConditionValue, false)
 +
end
 +
</syntaxhighlight>
 +
Example 4: "system_language"
 
<syntaxhighlight>
 
<syntaxhighlight>
n/a
+
-- set game language to users operating system language
 +
local sysLang = getProperty("system_language")
 +
 
 +
if sysLang == "English" then
 +
  game:setValue(VGameStandardLanguage, getObject("Languages[English]"))
 +
elseif sysLang == "German" then
 +
  game:setValue(VGameStandardLanguage, getObject("Languages[Deutsch]"))
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
 
<b><u>Arguments</u></b>
 
 
property: <br/>
 
"string" - The requested property to retrieve. Currently supported properties: "platform" ("win"/"mac") <br/>
 
"steam_initialized" (true/false depending if the steam_api was loaded and client is connected, false if the operation failed)
 
 
Flags: none
 
 
Return: property <br/>
 
requested property value
 
{{i18n|GetProperty}}
 

Revision as of 22:41, 30 April 2015

getProperty

Available since: v4.1
Return the requested property.

Lua Syntax:

getProperty(property)

Arguments

property

"string" - The requested property to retrieve. Currently supported properties: "platform" ("win"/"mac"),
"steam_initialized" (true/false depending if the steam_api was loaded and client is connected, false if the operation failed),
"galaxy_initialized" (true/false depending if the gog galaxy_api was loaded and client is connected, false if the operation failed),
"system_language" Returns English name of system language or "unknown" if language could not be retrieved.

Flags

Return Values

property
requested property value.

Examples

Example 1: "platform"

-- if platform equals windows then do some action else if mac do some other action
if getProperty("platform") == "win" then
  getObject("Conditions[win?]"):setValue(VConditionValue, true)
elseif getProperty("platform") == "mac" then
  getObject("Conditions[mac?]"):setValue(VConditionValue, true)
end

Example 2: "steam_initialized"

-- let's check if steam has initialized & set a value based on return value
local steamLoaded = getProperty("steam_initialized")

if steamLoaded then
  getObject("Conditions[steamLoaded?]"):setValue(VConditionValue, true)
else
  getObject("Conditions[steamLoaded?]"):setValue(VConditionValue, false)
end

Example 3: "galaxy_initialized"

-- let's check if gog galaxy has initialized & set a value based on return value
local galaxyLoaded = getProperty("galaxy_initialized")

if galaxyLoaded then
  getObject("Conditions[galaxyLoaded?]"):setValue(VConditionValue, true)
else
  getObject("Conditions[galaxyLoaded?]"):setValue(VConditionValue, false)
end

Example 4: "system_language"

-- set game language to users operating system language
local sysLang = getProperty("system_language")

if sysLang == "English" then
  game:setValue(VGameStandardLanguage, getObject("Languages[English]"))
elseif sysLang == "German" then
  game:setValue(VGameStandardLanguage, getObject("Languages[Deutsch]"))
end