Python scripts in the Blender GE don’t know what “True” and “False” are for some reason. 1 and 0 should be used instead (even when you are changing the value of a Blender boolean property).
Is this true in Linux or any other OS? It’s not true in Windows.
um, I believe that is taken out of context. I think you use T/F in the GE logic Bricks, but when using T/F in python script language you are to use 0 or 1?
um, I believe that is taken out of context. I think you use T/F in the GE logic Bricks, but when using T/F in python script language you are to use 0 or 1?
Perhaps?
No. In python, I only use True or False for bools. Never 1 or 0. I’ve never had a problem with it.
I’m on Linux, and it’s the same situation that blendenzo described.
Additionally, when using logic bricks (like a property sensor/actuator) you must refer to a boolean value via TRUE/FALSE - integers don’t seem to work as they would in scripts.
Wait a minute, In programming doesn’t 1=true and 0=false
Yes.
I always use True or False for bools because if someone else reads my code it’s easier to understand.
Blendenzo wrote that BGE doesn’t know what True and False is. This isn’t true in Windows. If it’s true for other OS, I’d like to know so I can change the way I handle bools.
I’m on Linux, and it’s the same situation that blendenzo described.
What linux distro are you using? I just tried it on PCLinuxOS (Blender 2.44) and it doesn’t have a problem with using True or False for a bool. Are the linux distros that different?
Wow… I honestly don’t know why it’s working for you. I’ve tried True/False on Windows (98SE and XP Pro, full Python install and no Python install) and Linux systems (Ubuntu and Mint, which are fundamentally the same, both are variants of Debian) and never had it work. I’ve tried it with Python 2.4 and Python 2.5.
PlantPerson sent me an email a while back asking how to make booleans work in a Python script for his Zark game. He was using True/False (on Windows) and it was not working for him. When he switched to 1/0 everything worked fine.
I’m with Social on this one. 1/0 seems to work for everyone, but True/False only works for some. Stick with 1/0 to be safe (or just define True and False at the top of your script, so that everyone’s computer knows what they mean).
That really surprises me. I wonder why people didn’t mention it with they played the game I made (Blender Puzzle Ball). That’s all it uses. True and False for bools. There’s well over a hundred True/False statements in that. The custom cursor. The menu. The rotation.
If people played an executable that was created on your system (where True/False are apparently both defined), then I would assume that those definitions carried over with the stand-alone.
If people played an executable that was created on your system (where True/False are apparently both defined), then I would assume that those definitions carried over with the stand-alone.
I realize that. But I also posted the blend and it was downloaded over a hundred times and no one mentioned it. And True and False aren’t defined.
Maybe because the executable was already there, so if they found any problems with the .blend they would just go to the executable, instead of informing you and asking/waiting for a fix.
I mean take a look at how many people downloaded your game (100 right), and compare that with how many individuals posted.
And True and False aren’t defined.
They were defined by your version of blender when the standalone was formed (Because they would have to be - implicitly or explicitly - in order to work).
But again, this entire issue is a complete “bikeshed”:
I assure you: Anyone who would bother to read, understand or modify your code won’t have any trouble figuring out what 1 and 0 mean.
Actually using True/False could potentially be more confusing, because who is to say that True/False can’t be set to a string, or some other arbitrary value. Heh, I would actually have to check if True/False is set to 1/0 before using True/False.