Create account / Log in

Dynamic Property Set Value: Why this formula does'nt works?

Talk about module design ideas and techniques.

Moderators: Tim M, uckelman

Dynamic Property Set Value: Why this formula does'nt works?

Postby Parduz » October 5th, 2019, 12:15 am

I'm building a "Door" Prototype. Inside there's a dynamic property called "DoorStatus", which represent the ... well... door status :D

0 means the door is closed
1 means the door is open
2 means the door is destroyed.

So my DoorStatus dynamic property is configured this way:
Code: Select all
Name: DoorStatus
Value: 0
Is Numeric: CHECK
Min: 0
Max: 2
Wrap: UNCHECK


I want to switch from 0 to 1 and viceversa with the same key command, but do nothing if the door is destroyed.
So i've made a Open / Close command that set value directly with this expression in the New value field:

Code: Select all
{If(DoorStatus==0,1,If(DoorStatus==1,0,DoorStatus))}


To me, this line means that
if DoorStatus is 0, it returns 1
else if DoorStatus is 1, it returns 0
else it returns the current value of DoorStatus (so, not changing it).

But this does'nt works; when i give the key command:
if DoorStatus is 0, it becomes 1 (and this is ok)
if DoorStatus is 1, it remains 1 (why?)
if DoorStatus is 2, it becomes 1 (why?)

The same expression put in a calculated property (NextDoorStatus) works as expected.

Why i don't get the expected results and instead it always returns 1?
Parduz
 
Posts: 32
Joined: January 13th, 2009, 1:36 pm
Location: Bologna, Italy

Re: Dynamic Property Set Value: Why this formula does'nt wor

Postby kerkael » October 6th, 2019, 12:05 am

Hi, when you place DoorStatus before the == symbol, it's interpreted and calculated.
When you place it as a value, for your last assigned else, it's treated as ... text ! try by encapsulating the last between $$ so it will be interpreted :
Code: Select all
{If(DoorStatus==0,1,If(DoorStatus==1,0,$DoorStatus$))}
kerkael
 
Posts: 111
Joined: December 1st, 2017, 3:03 pm


Return to Module Design

Who is online

Users browsing this forum: MSN [Bot] and 7 guests