how to do an if logic block?

I have two ships or more ships to choose from at the start.

How can I say "if (player chooses blue_ship) ; then blue_ship is the one controlled by the keyboard when the level starts…

I’m trying to learn to do some of this in python but even though I can write some mean bash scripts I can’t seem to figure out the python/blender thing. Mainly because there are so many examples of the same things done in different ways and I have not clue whether I’m doing something wrong or the code is in some way depricated.

You could use the property sensor to check properties. As far as the BGE api, it has been seeing some changes, so you are likely to encounter old examples. Some of these may include deprecated methods.

The 2.5 api is a lot like the 2.49 api, so must of the stuff you find for them should be current enough. Some 2.48 stuff might work as well.

I don’t see how I can use the property sensor since the property sensor is only for the same object.

I want to have a choice screen in the menu… red vs blue, then have the player enter the game either red or blue.

I just can’t see how using the property sensor helps that?

Another thing I can’t figure out is the state actuator… what the hell is a “state mask group”? and how do you get one?

See really what I want to be able to do is like an if, for, while loop using logic blocks.

I have been learning python as well: I have found that in Linux if I run Blender through the terminal then I can see what errors, (if any,) come up when my scripts are called. I believe that in Windows Blender runs through command prompt anyway. So all you really need to do is check the command prompt window that is called when Blender starts. You need to take it slowly and check the console at each step.

If you have piles of output, a useful trick is to copy the output of interest into a text editor where it can be studied in detail.

Also, I found this tutorial on how to convert Blender 2.4x scripts into Blender 2.5x It has a lot of useful ideas.

Hope this helps
.

There is a tutorial here that covers state mask groups. It is for Blender 2.4x.

Blender 2.5x is slightly different, I have atached a screen shot showing the state mask groups with Blender 2.54 that I am using to switch cameras on a game I am working on

.

Attachments


Just so you know, the question is wrong.
All logic bricks are considered an “if statement”, if you are using the keyboard sensor, with L, then it’s basically saying:
If L is pressed -> Controller -> Actuator.

Now, if your doing a pick player kind of thing, the best way to go is with python, but it’s very possible with logic bricks.

Just make an overlay scene, with nothing but an empty with your properties. Then if player picks blue, send a message to the playing scene saying that the player picked Blue. If the player picked red, do the same.

Now, that’s a very brief example of how to do it, but explore the logic bricks and game engine, it’d shouldn’t be too hard to do :slight_smile:

Good luck.

@Irvine thnks for the link to the masks tut I wouldn’t have found it until I needed to switch cameras… heh…

@Linkxgl

You are right the question is wrong… I should have just made the subject 42 (shameless hitchhikers pun) and left it at that… but I had to write something and I’m really really new to blender game logic though I’ve been doing game modelling with blender and exporting to other engines for years. I’ve been beating my head against a wall now for a couple of weeks and not getting very far. I have two fighters that move and shoot, and blow up when hit and one level and one menu.

Just before reading this I tried to make a second menu to pick red or blue team. Thinking I would have to do this later to make my ships spawn when they are killed, I made a copy of one of my ships, and then tried to use an (edit object)-(add object) actuator linked to an allways sensor attached to an empty and it doesn’t show up.

I think this is going to be a long painful process…

I have not given it much thought, (I have my own problems,) but you should be able to switch planes by using the mask group thingy. I am not sure exactly how, but I think something along the lines of having the two planes on different layers and switching between the two???

You are correct though, “a [very, very] long painful process”. What is really causing me problems is the texturing. I don’t know if you have tried some of the more exotic textures yet, but they don’t work well, (if at all,) in the BGE and you have to use various tricks to get them to render.

To make matters worse, I am struggling with a crappy integrated Intel graphics chip; and, to add to my problems, the Linux driver for this chip has a long standing bug, (due to Intel, not Linux,) that affects Blender 2.5x much more than it affected 2.4x

Anyway, best of luck
.