Difference between revisions of "ToggleCondition (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "{| class="wikitable" style="width:100%" |- ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By |- | toggleCondition("c") || Defi...")
 
Line 19: Line 19:
 
function toggleCondition(c)
 
function toggleCondition(c)
 
  if getObject("Conditions[" .. c .. "]"):getBool(VConditionValue) then
 
  if getObject("Conditions[" .. c .. "]"):getBool(VConditionValue) then
   getObject("Conditions[" .. c .. "]"):setValue(VConditionValue, false) else getObject("Conditions[" .. c .. "]"):setValue(VConditionValue, true)
+
   getObject("Conditions[" .. c .. "]"):setValue(VConditionValue, false)
 +
  else getObject("Conditions[" .. c .. "]"):setValue(VConditionValue, true)
 
  end
 
  end
 
end
 
end

Revision as of 20:19, 14 August 2014

Name Type By
toggleCondition("c") Definition AFRLme

This small function allows you to quickly return the boolean value of a condition; should only be used with if queries.

Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2. To use this function you should create an execute a script action containing...

toggleCondition("condition_name")

Main Script

function toggleCondition(c)
 if getObject("Conditions[" .. c .. "]"):getBool(VConditionValue) then
  getObject("Conditions[" .. c .. "]"):setValue(VConditionValue, false)
  else getObject("Conditions[" .. c .. "]"):setValue(VConditionValue, true)
 end
end

Syntax Breakdown

Name Type Description
c "string" This should be a "string" value containing the name of the condition you want to toggle the boolean value of.