Math problem with boolean

gameviccigamevicci Member, PRO Posts: 306
edited February 2012 in Working with GS (Mac)
Hi guys, here's the problem:

I have 10 boolean attribute and 1 integer attribute
I want that the integer attribute is boolean1+boolean2+boolean3 etc, but It doesn't work

for example: If I change the integer attribute to boolean1, the integer become 1
but If I change the integer attribute to boolean1+boolean2, the integer become 0 (even if boolean1 is true and boolean2 is false).

Is it possible to make an addition of boolean attributes?
Thanks !

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Never tried to add booleans before.

    Could you just use intergers in place of the booleans, having 0 in place as false, and 1 in place of true?

    Then you can add those together no problem
  • old_kipperold_kipper Member Posts: 1,420
    edited February 2012
    John's system does work but it seems a little strange that booleans can be written as 0 or 1 (as well as false/true) and not be read as that. If you don't want to change your booleans to integers you could use a rule for each boolean that adds or subtracts from an integer based on true or false (1/0).
  • gameviccigamevicci Member, PRO Posts: 306
    edited February 2012
    Hi Jonh! Thanks for answering
    I have 94 attribute, so 94 integer are too heavy for the memory on my 3gs

    old_kipper's solution is what I was thinking to use.

    Is it possible that in previous GS version the addition of boolean worked well?

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited February 2012
    My guess would be that it lets you use 0,1 to set true or false in a boolean, but doesnt actually hold the value of 0 and 1. In the value theres no place to put a number, only the check box to indicate true of false. So thats only a way to change the states, and they dont actually have that value held in them. Just like if you display a boolean in a display textm it displays true or false because thats the actual value its holding, not 0/1.

    Ive also never noticed a differnce in memeroy by using differnt attributes types.I have a couple projects i started a while ago that have 500+ interger attributes that run fine.

    So i bet your gonna have to change them, you can use index if theres no negative numbers, which take up less memory per say.

    cheers
  • gameviccigamevicci Member, PRO Posts: 306
    Thanks John I will try!
Sign In or Register to comment.