Value in a "Property" sensor

I know I can set a value by typing in a number (in the “Value” field of a property sensor) for a property to be compared to “Equal, Not Equal”, etc. But what if I want to use an other property (on the same object) instead of a numeric entry in the “Value” field? If I just type in the name of the other property, it acts like a zero value, because it’s text of course. Is there a proper syntax to type, maybe brackets, quotes, = sign, or whatever?

You can do this with an expression controller.
you want to activate an actuator if property cakes is greater than property pizzas:
[property sensor: cakes changed] — [expression: cakes > pizzas] — [actuator]

As I wrote in a previous thread, this is the role of the expression controller / Python controller. An example:
expression.blend (477 KB)

There are two different controllers; one using only expressions, the other moving some sensing logic into sensors.

The way it is evaluated is (for the only-expression logic):

  • Is the sensor positive (PlaceBet)?
  • Is the bet more than zero?
  • Is the bet not more than 3?
  • Is the bet less than or equal to the credits

That’s not exactly what I want to do. Let’s say an object “Cube”, has three sensors. One is a keyboard sensor, and two are property sensors. All three sensors are connected to an “And” controller, which in turn is connected to an actuator. The “Cube” also has two properties, one called “Cakes” and one called “Pizzas” and both are integer types. These two properties change as the game plays, but what I want to do is that when the key is pressed, “Cakes” should be greater than 0, and also “Pizzas” needs to be not greater than “Cakes”. But I can’t just type “Cakes” in the value field of the “Pizzas” property sensor. It only accepts numerical input, but not the name of another property (i.e. a variable).

Why can’t you use the expression controller, as demonstrated? Look at the final condition in the expression controllers in the demo above.

Cakes > 0 AND NOT Pizzas > Cakes

Well because the expression controller needs to be connected to a sensor. If I use an always sensor, with the expression controller, how can I have it work only when the key is pressed? I can use the keyboard sensor to an “AND” controller, and use property sensors to the same “AND” controller, so three things need to be true before the actuator does what it does. The key must be pressed, and the property “PlayerCredits” has to be >0 (That would be one property sensor checking for that). And, the other property “PlayerBet” has to be >1 (that’s the other property sensor checking that). And maybe I need another property sensor to check if “PlayerBet” is < 4, but even then, how can I compare PlayerBet to be less than or equal to ( <= ) PlayerCredits? Because that would need to be an always sensor, and then that will always trigger the actuator because I can’t evaluate the expression AND check the keypress. I get into a loop that doesn’t make sense.

The controller will only be triggered when connected sensors trigger it. Hence, connecting a Keyboard sensor will suffice to trigger it, and you must also check that it is positive (if SENSOR_NAME …).
Read the file expression - it does all of this.

agoose77, your way works. But I see many other things in your example that I had never seen used that way, nor in the documentation that I could find. One thing is almost EXACTLY what I was trying to ask, but not quite. I see in your example, you have an empty called “ExpressionAndSensors” and one of the actuators (RemoveCredits) is adding the negative value of the PlayerBet to the property PplayerCredits. That’s great, and it works of course. BUT…I see that you can use the variable name (-PlayerBet) in the “value” field of the actuator. But I was trying to use a variable name in the “value” field of a property SENSOR instead, and it did not work. So am I correct that you can use variable names (i.e. property names) in the “value” field of actuators, but not in the “value” field of sensors?

Another thing that I see is that you have a property sensor on this object of the type “interval” with min=1 and max=3, which I see keeps the bet in the correct range of 1 - 3. But I had only seen examples of using this “interval” as a timer. Where did you find out all this good stuff?

Finally, a BIG thank you for all your help!

The other empty, expressionsonly is pure expressions. The propriety actuator allows a property name in the value because you can’t set a value otherwise, whilst expressions allow you to read the value.
Interval is used for timers because of the fact that we didn’t have greater than modes for the sensors until 2.74 (I think).