Difference between revisions of "CheckCond (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
! 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 | ||
|- | |- | ||
− | | checkCond("c") || Definition || AFRLme | + | | checkCond("c", path) || Definition || AFRLme |
|} | |} | ||
− | This small function allows you to quickly return the boolean value of a condition | + | This small function allows you to quickly return the boolean value of a condition. |
+ | |||
== 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/> | ||
− | 2a. | + | 2a. Usage Example #1: check if globally accessed condition returns <span class="green">true</span>. |
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
if checkCond("condition_name") then | if checkCond("condition_name") then | ||
-- add some actions here... | -- add some actions here... | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | 2b. | + | 2b. Usage Example #2: check if globally accessed condition returns <span class="red">false</span>. |
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
if not checkCond("condition_name") then | if not checkCond("condition_name") then | ||
-- add some actions here... | -- add some actions here... | ||
end | end | ||
+ | </syntaxhighlight> | ||
+ | 2c. Usage Example #3: check if condition linked to current scene returns <span class="green">true</span>. | ||
+ | <syntaxhighlight lang="lua> | ||
+ | if checkCond("condition_name", game.CurrentScene) then | ||
+ | -- add some actions here... | ||
+ | end | ||
+ | </syntaxhighlight> | ||
+ | 2d. Usage Example #4: check if globally accessed condition returns <span class="green">true</span> via '''if lua result''' action part. | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | return checkCond("condition_name") | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
== Main Script == | == Main Script == | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
− | function checkCond(c) | + | function checkCond(c, path) |
− | + | if path == nil then c = Conditions[c] else c = path.Conditions[c] end -- check global access or direct link | |
+ | return c -- return the boolean value belonging to the condition | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
== Syntax Breakdown == | == Syntax Breakdown == | ||
Line 36: | Line 50: | ||
|- | |- | ||
| c || "string" || This should be a "string" value containing the name of the condition you want to check the boolean value of. | | c || "string" || This should be a "string" value containing the name of the condition you want to check the boolean value of. | ||
− | |} | + | |- |
+ | | path || path || This should contain the direct path to the condition, for example: <span class="inlinecode">game.CurrentScene</span> or <span class="inlinecode">Scenes["example"]</span> or <span class="inlinecode">Characters["Tom"]</span>, etc. | ||
+ | |}{{toc}} |
Latest revision as of 15:02, 23 August 2022
Name | Type | By |
---|---|---|
checkCond("c", path) | Definition | AFRLme |
This small function allows you to quickly return the boolean value of a condition.
Instructions
1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. Usage Example #1: check if globally accessed condition returns true.
if checkCond("condition_name") then
-- add some actions here...
end
2b. Usage Example #2: check if globally accessed condition returns false.
if not checkCond("condition_name") then
-- add some actions here...
end
2c. Usage Example #3: check if condition linked to current scene returns true.
if checkCond("condition_name", game.CurrentScene) then
-- add some actions here...
end
2d. Usage Example #4: check if globally accessed condition returns true via if lua result action part.
return checkCond("condition_name")
Main Script
function checkCond(c, path)
if path == nil then c = Conditions[c] else c = path.Conditions[c] end -- check global access or direct link
return c -- return the boolean value belonging to the condition
end
Syntax Breakdown
Name | Type | Description |
---|---|---|
c | "string" | This should be a "string" value containing the name of the condition you want to check the boolean value of. |
path | path | This should contain the direct path to the condition, for example: game.CurrentScene or Scenes["example"] or Characters["Tom"], etc. |