Difference between revisions of "SetConditions (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "{| class="ts" style="width:100%" |- ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By |- | setConditions({t}, val) || Definiti...")
(No difference)

Revision as of 14:34, 21 August 2022

Name Type By
setConditions({t}, val) Definition AFRLme

This small function allows you to quickly set or toggle the boolean value of multiple conditions.


Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. Usage example #1: update all listed conditions to true

setConditions({"example1", "example2", "example3"}, true)

2b. Usage example #2: toggle all listed conditions

setConditions({"cond1", "cond2", "cond3"})

2c. Usage example #3: update all listed conditions via linked table to true

local tbl = {"cond1", "cond2", "cond3"}

setConditions(tbl, true)


Main Script

function setConditions(t, val)
 for i = 1, #t do -- iterate through table stored in the t input variable
  if val == nil then
   if Conditions[ t[i] ].Value then Conditions[ t[i] ].Value = false else Conditions[ t[i] ].Value = true end -- toggle condition
  else
   Conditions[ t[i] ].Value = val -- update all conditions listed in t variable to val
  end
 end
end


Syntax Breakdown

Name Type Description
t table This should be a table or linked table containing the "names" of the conditions you want to update the boolean value of.
val boolean or nil This should contain a boolean value of true or false, or nil if you want to toggle the conditions.