Difference between revisions of "Conditions and Values"
Line 6: | Line 6: | ||
You can create 2 types of conditions:<br/> | You can create 2 types of conditions:<br/> | ||
− | 1. Variable: this is a single condition which contains a boolean value of true or false.<br/> | + | 1. <strong>Variable</strong>: this is a single condition which contains a boolean value of true or false.<br/> |
− | 2. Combined: this allows you to link 2 single conditions & set "and", "or" query to link to an object. | + | 2. <strong>Combined</strong>: this allows you to link 2 single conditions & set "and", "or" query to link to an object. |
Revision as of 19:11, 26 August 2013
Conditions & Values are a fundamental necessity when it comes to game development as they allow us to dictate the events that can take place, have taken place or have yet to take place. They can also be used in if else queries to determine if an event, or multiple events should be allowed to occur based on a conditions value or the integer number of a Value.
Conditions are boolean based & contain either the value of true or false. Besides the obvious use of them in an if else query, they can also be linked directly to objects, dialogs & interface buttons via the properties tab for the aforementioned objects, to quickly determine if the object is active (shown) or disabled (hidden); if disabled then all images & animations for the object will be hidden & all actions associated with the object will also be disabled - this is very useful for quickly changing the environment of the scene or any other scenes for that matter, regardless of whether they are a playable scene, cut-scene or menu.
You can create 2 types of conditions:
1. Variable: this is a single condition which contains a boolean value of true or false.
2. Combined: this allows you to link 2 single conditions & set "and", "or" query to link to an object.
Combined conditions can be useful, but I find Values are a lot more flexible when it comes to multiple conditions needing to met for certain events to be performed. The in editor if query system is not as flexible as writing if queries with Lua mind as there is no method for creating the "and" or "or" operators. Also there is no "elseif" which means that for each if you create that there should also be the same amount of end if.
Values are "string" & integer based & are a lot more flexible than conditions. We can create "string" values, integer values & random integer values between x number (min) & y number (max). We also have multiple options inside of the "set value" action part such as directly setting a new integer value (=), adding to current value (+), subtracting from current value (-), multiplying current value (*) & finally: dividing the current value (/). Having said that; we can't set a new string value via the "set value" action part, nor can we use the string value in an if else query; instead it has to be done via a simple bit of Lua scripting (see below).
-- for simplicities sake, this should be done inside of an "execute a script" action part!
local val = getObject("Values[add value name here]") -- store value into a variable
local str = val:getStr(VValueString) -- store linked values "string" value into a variable
val:setValue(VValueString, "add new string value here") -- create a new string value
-- quick if query example
if str == "hello world" then
return true
else
return false
end
Values, both integer & "string" can be called inside of the displayed text action parts. Currently I do not see much point in calling string values inside of displayed text until support for true text input has been added to Visionaire Studio but the integer value can be used for various different things such as keeping track of money, credits, score of a game or a puzzle etc.
-- let's say I have an integer value called "money" which contains the initial value of 100...
I currently have $<v=money>. -- would display "I currently have $100."
-- or let's say I have a "string" value "char1" which contains a characters name; let's say the characters name is "Fred"...
My name is <vs=char1>. -- would display "My name is Fred."