|
|
(One intermediate revision by one other user not shown) |
Line 1: |
Line 1: |
− | ==getProperty==
| + | #REDIRECT [[Global Command: getProperty]] |
− | | |
− | <div class="command-min-version-info">Available since: <span class="command-min-version">v3.7.1</span></div>
| |
− | | |
− | <div class="command-doc">Return the requested property.</div>
| |
− | | |
− | 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"
| |
− | <syntaxhighlight>
| |
− | -- 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>
| |
− | 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: "system_language"
| |
− | <syntaxhighlight>
| |
− | -- 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>
| |