Difference between revisions of "GetProperty"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m
Line 1: Line 1:
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
+
==getProperty==
<span class="bold">Command History</span>
 
<div class="mw-collapsible-content">
 
<div class="alt-bg">Available since v3.7</div>
 
<div>system_language property added to v3.8</div>
 
</div></div>
 
  
 +
<div class="command-min-version-info">Available since: <span class="command-min-version">v3.7.1</span></div>
  
Return the requested property.
+
<div class="command-doc">Return the requested property.</div>
 
 
 
 
Syntax:
 
<syntaxhighlight>
 
getProperty(property)
 
</syntaxhighlight>
 
 
 
  
 +
Lua 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),
 +
:"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"
 
Example 1: "platform"
 
<syntaxhighlight>
 
<syntaxhighlight>
-- if platform equals windows then do some action else if mac do some other action!
+
-- if platform equals windows then do some action else if mac do some other action
 
if getProperty("platform") == "win" then
 
if getProperty("platform") == "win" then
getObject("Conditions[win?]"):setValue(VConditionValue, true)
+
  getObject("Conditions[win?]"):setValue(VConditionValue, true)
 
elseif getProperty("platform") == "mac" then
 
elseif getProperty("platform") == "mac" then
getObject("Conditions[mac?]"):setValue(VConditionValue, true)
+
  getObject("Conditions[mac?]"):setValue(VConditionValue, true)
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
Example 2: "steam_initialized"
 
Example 2: "steam_initialized"
 
<syntaxhighlight>
 
<syntaxhighlight>
-- let's check if steam has initialized & set a value based on return value!
+
-- let's check if steam has initialized & set a value based on return value
local steamLoaded == getProperty("steam_initialized")
+
local steamLoaded = getProperty("steam_initialized")
  
 
if steamLoaded then
 
if steamLoaded then
getObject("Conditions[steamLoaded?]"):setValue(VConditionValue, true)
+
  getObject("Conditions[steamLoaded?]"):setValue(VConditionValue, true)
 
else
 
else
getObject("Conditions[steamLoaded?]"):setValue(VConditionValue, false)
+
  getObject("Conditions[steamLoaded?]"):setValue(VConditionValue, false)
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
Example 3: "system_language"
 
Example 3: "system_language"
 
<syntaxhighlight>
 
<syntaxhighlight>
-- let's check the current users operating system language & store it in a variable!
+
-- set game language to users operating system language
local sysLang == getProperty("system_language")
+
local sysLang = getProperty("system_language")
  
 
if sysLang == "English" then
 
if sysLang == "English" then
game:setValue(VGameStandardLanguage, getObject("Languages[English]"))
+
  game:setValue(VGameStandardLanguage, getObject("Languages[English]"))
 
elseif sysLang == "German" then
 
elseif sysLang == "German" then
game:setValue(VGameStandardLanguage, getObject("Languages[Deutsch]"))
+
  game:setValue(VGameStandardLanguage, getObject("Languages[Deutsch]"))
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
 
<span class="bold underline">Arguments</span>
 
 
<span class="bold">property</span>: "string" <br/>
 
* "platform" (returns "win" or "mac" depending on users operating system)
 
* "steam_initialized" (true/false depending if the steam_api is successfully loaded & client is connected)
 
* "system_language" (returns users system language in english; english, german, spanish etc)
 
 
 
<span class="bold underline">Flags</span>
 
 
none
 
 
 
<span class="bold underline">Return</span>
 
 
<span class="bold">property</span> <br/>
 
The requested property value
 
{{i18n|GetProperty}}
 

Revision as of 17:11, 22 November 2013

getProperty

Available since: v3.7.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),
"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: "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