text attributes versus integer attributes
I'm posting this because I thought it might help someone else.
I was struggling with a game that seemed really buggy, and I was using a lot of text attributes for my rules. Stuff like this:
If attributeA is cow and attributeB is animal, do something.
I tried both "is" and "contains" to make my rules, and the behavior just never made sense. Sometimes my rule would fire and sometimes it wouldn't. (I checked to see if there were invisible spaces in my text variables, and there didn't seem to be.)
So finally, I switched to using integer attributes. I changed attributeA from (text:cow) to (integer:1) and attributeB from (text:animal) to (integer:1). Then I made my rule using numbers instead of text:
If attributeA=1 and attributeB=1, do something.
Now it works!
It's harder to follow the logic using numbers as attributes instead of words, but if you're fighting with code that seems like it should be working and isn't, and you're using text variables, changing them to integers could be something worth trying.
I'm curious whether anyone else has encountered this problem before.
I was struggling with a game that seemed really buggy, and I was using a lot of text attributes for my rules. Stuff like this:
If attributeA is cow and attributeB is animal, do something.
I tried both "is" and "contains" to make my rules, and the behavior just never made sense. Sometimes my rule would fire and sometimes it wouldn't. (I checked to see if there were invisible spaces in my text variables, and there didn't seem to be.)
So finally, I switched to using integer attributes. I changed attributeA from (text:cow) to (integer:1) and attributeB from (text:animal) to (integer:1). Then I made my rule using numbers instead of text:
If attributeA=1 and attributeB=1, do something.
Now it works!
It's harder to follow the logic using numbers as attributes instead of words, but if you're fighting with code that seems like it should be working and isn't, and you're using text variables, changing them to integers could be something worth trying.
I'm curious whether anyone else has encountered this problem before.