The Blog

About Me


Marius Oberholster Hey! I'm having an incredible learning experience, not only learning how Blender works (yes, still learning), but also about Open-Source and the incredible software available. Stick around!

Expressions

Posted by Marius Oberholster on Monday, January 20, 2014 Under: Quick Blog Tutorial
Hey all!!

Yes, expressions, but not as in:
:-)
[^^,]
('c ',)
or even
q^_^p

No, we're talking, the expressions we use in programming! Oh yes, we're going to get to grips with some of it today!


An expression is something that acts as a filter. It can be explained as follows:

I want something to go through, only when it is in a certain range, for example:

I have a speedometer, but the steering should have no effect on movement below a certain speed. Now, I'm going to write something like this in the expression controller:
speed > 10 AND speed < 250

Now, when the following is aligned:
Property > Expressions > Action

The property will be set to detect any property change and only when speed changes, the expression is checked. If the expressions passes as true, unless tested for false, in which case the expression still needs to be valid, then, and only then will the action take place.

Let me explain it like this, the game has 60 logic tics a second, so this is how often, for example, the game checks the property, to see if it has changed:
----------------------------------------------------------------------------------------------------------------------------------

When the property changes, it happens only so many times in the course of the game:
-------------------------------------------

But, the expression is only valid for a few of those changes or in this case, speed's changes:
-------------------

So you can see, an expression acts like a filter, to deter the actuator from functioning more often than it should. The same goes for the other controllers. They are there to act as filters or channels. Some are more open than others, but they all determine the flow or outcome of the sensor's activity and validity.

In the expression controller, you can use the following (All-caps is not required btw):
 - Property names without spaces
 - *, /, +, -, ()
 - And, Or, Not, If
 - <, >, >=, <=, =, !=
 - Numbers
 - True and False
 - Quotes for grammatical or lingual testings, ie, testing if a string contains a certain letter or combination, like for battleship

And that's it for this little QBT! I really hope this helps you overcome some issues you've had with your games and that you will now be able to make those actuators only fire when they need to; no more misfires!

Have a wonderful day everyone!!

Thank YOU!!!!!!!!

Sources:
 - JESUS
 - http://wiki.blender.org/index.php/Doc:2.6/Manual/Game_Engine/Logic/Controllers/Expression
 - http://wiki.blender.org/index.php/Doc:2.6/Manual/Game_Engine/Logic/Controllers/Expressions
 - http://www.tutorialsforblender3d.com/LogicBricks/Controllers/Expression/Expression_Controller.html
 - http://www.tutorialsforblender3d.com/LogicBricks/Controllers/Expression/Expression_Controller_Examples.html

In : Quick Blog Tutorial 


Tags: jesus  qbt  new  controller  expression  and  true  false  god  real  know jesus 
Social
(+27) 073 104 2834   |   marius.oberholster@gmail.com   |   Contact

Make a free website with Yola