Difference between revisions of "CheckCond (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m
m
Line 11: Line 11:
 
== 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. Usage Example #1: check if globally accessed condition returns <span style="color:lightgreen">true</span>.
+
2a. Usage Example #1: check if globally accessed condition returns <span class="green">true</span>.
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
if checkCond("condition_name") then
 
if checkCond("condition_name") then
Line 23: Line 23:
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
2c. Usage Example #3: check if direct link condition returns <span class="lightgreen">true</span>.
+
2c. Usage Example #3: check if direct link condition returns <span class="green">true</span>.
 
<syntaxhighlight lang="lua>
 
<syntaxhighlight lang="lua>
 
if checkCond("condition_name", game.CurrentScene) then
 
if checkCond("condition_name", game.CurrentScene) then
Line 29: Line 29:
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
2d. Usage Example #4: check if globally accessed condition returns <span class="lightgreen">true</span> via if lua result action part.
+
2d. Usage Example #4: check if globally accessed condition returns <span class="green">true</span> via if lua result action part.
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
return checkCond("condition_name")
 
return checkCond("condition_name")

Revision as of 15:01, 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 direct link condition 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.