Problem with rules & real attributes

opaopa Member Posts: 35
edited June 2015 in Working with GS (Mac)

Hi!

I have a problem with rules and real attributes.

I have two real attributes:

real1 = 0.1
real2 = 0.2

And rule:

IF real1 = real2

THEN

display text: Hello World!

Any suggestion why my actor shows that Hello World! -text?
Doesn't rules work with decimals?

Comments

  • ArmellineArmelline Member, PRO Posts: 5,369

    I just tried this and the display text doesn't show up. Can you show us a screen shot of the rules, and of the attributes?

  • opaopa Member Posts: 35

  • ArmellineArmelline Member, PRO Posts: 5,369

    @opa said:

    Try using 1.1 instead of 1,1.

  • opaopa Member Posts: 35

    @Armelline said:

    Hi, thanks for your help!

    I tried that, but It's not possible?

  • opaopa Member Posts: 35
    edited June 2015

    @Armelline

    I have result table, which shows times for player1, player2, player3 and player4.

    And also actors, which shows players position after each level.

    For example, if players' times are like this, Creator seems to think that player1 and player4 has same time (which is not true):

    Player1 = 12.13 =position 1
    Player2 = 14.12 =position 3
    Player3 = 19.22 =position 4
    Player4 = 12.11 =position 1

  • ArmellineArmelline Member, PRO Posts: 5,369

    @opa said:
    I tried that, but It's not possible?

    Perhaps it's a regional thing then. Perhaps @BlackCloakGS or someone from GameSalad can shed some light.

    It seems the most likely culprit. Not sure why you'd be prevented from putting a period in that attribute though.

  • BlackCloakGSBlackCloakGS Member, PRO Posts: 2,250

    Using equals with real numbers is always problematic. If i remember correctly if two real attributes are with in .01 of each other they are consider equal. You should use greater than or less than operators.

  • opaopa Member Posts: 35

    @BlackCloakGS said:
    Using equals with real numbers is always problematic. If i remember correctly if two real attributes are with in .01 of each other they are consider equal. You should use greater than or less than operators.

    OK, I didn't know that.

    I've spent too many hours with this, because I thought that there was something wrong with my attributes or something.. :# I'll try to make changes, thanks for your answer!

  • opaopa Member Posts: 35
    edited June 2015

    I made changes and now it works!

    I did it like this:

    IF
    level_best_time < player1_time+0.01
    level_best_time > player1_time-0.01

    THEN

    Player1_position = 1

    etc.

    Thanks again! B)

  • ArmellineArmelline Member, PRO Posts: 5,369
    edited June 2015

    Edit: Never mind, I completely missed one of your posts. Confusion avoided :D

Sign In or Register to comment.