Difference between revisions of "Workflow Functions"
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "What is a workflow function? A workflow function is a function that you can script to save yourself time by reducing the amount of work you need to do. The function could perf...") |
|||
Line 9: | Line 9: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function setCond(cond, val, cs) | function setCond(cond, val, cs) | ||
− | if cs then cond = game.CurrentScene.Conditions[cond] else cond = Conditions[cond] end | + | if cs ~= nil then cond = game.CurrentScene.Conditions[cond] else cond = Conditions[cond] end |
-- + -- | -- + -- | ||
if val == nil then -- toggle | if val == nil then -- toggle | ||
Line 18: | Line 18: | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | Usage: | + | Usage example #1: set condition example as true, access globally |
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
− | setCond("example", true | + | setCond("example", true) |
+ | </syntaxhighlight> | ||
+ | Usage example #2: toggle condition example, access condition belonging to current scene | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | setCond("example", nil, true) | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 17:57, 20 August 2022
What is a workflow function? A workflow function is a function that you can script to save yourself time by reducing the amount of work you need to do. The function could perform one specific task, or it could perform multiple tasks.
Anyway, let's crack on...
Example #1: Condition
Script section > definition type script:
function setCond(cond, val, cs)
if cs ~= nil then cond = game.CurrentScene.Conditions[cond] else cond = Conditions[cond] end
-- + --
if val == nil then -- toggle
if cond.Value then cond.Value = false else Cond.Value = true end
else
cond.Value = val -- update condition based on val (true or false)
end
end
Usage example #1: set condition example as true, access globally
setCond("example", true)
Usage example #2: toggle condition example, access condition belonging to current scene
setCond("example", nil, true)