Convert Logic bricks to python scripts. how ?

i have a lots of logic bricks now…and its pretty mashed up…i want to convert it to a python script which i will use it with an always sensor…how to do that ?

i have several other scripts also…like bloom,mousemovement !

its an FPS game …BTW …

As far as I know, there is no automatic way to convert the logic bricks into Python script. However, porting the logic bricks into Python should be very straight forward. Each Sensor goes into a Controller that is a simple “AND” or “OR” operation.

Step 1) Replace all the and/or Controllers with Python controllers that simply do the same AND/OR operation.
Step 1.5) Test everything to ensure nothing has been broken.

Step 2) Remove all the Keyboard/Joystick/Mouse button sensors and access them directly in your Python though
Step 2.5) Test everything to ensure that nothing has been broken.
bge.logic.keyboard, bge.logic.joysticks, bge.logic.mouse, etc.

Step 3) Remove the Actuators that are easy to do. Things like ‘Property’ and movement actuators are pretty straight forward to replace with Python code
Step 3.5) Test everything again to ensure nothing has broken.

Step 4) Move the more difficult Actuators to Python. Things like ‘Action’ actuators that play animations require a bit of work to replace with Python code.
Step 4.5) That’s right, test again.

The python script equivalent to these W,A,S,D for forward,backward,left,right respectively. Please anyone as an example

You could do a movement script yourself using this as a template

keyboard = bge.logic.keyboard
w = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.WKEY]

glvZ = owner.getLinearVelocity(True)[2]

if w:
    owner.setLinearVelocity((0, 3, glvZ), True)

Simply do not do it.
Why would you want to replace one mess with another? Python is no magic thing that does everything better.

Better restructure the design of your logic. Keep things separate. E.g. separate shooting from movement.
If a tasks fits better with Python use Python.
If a task fits better with logic bricks choose Logic bricks. The Python controller is a logic brick too!

If you say “with an always sensor” … you haven’t thought about the logic you want.
“Always” (True Pulse) should be avoided as much as possible.
I guess you are not checking your mailbox 60 time per second. Why should your game do that?

Better define: What happens when?

Example:
When mouse is moved and left mouse button is presses … do this and that.
When space is pressed … do a jump.

You configure the When with sensors+controllers and the What with actuators.
If a required What is not there use a python controller. E.g. copy attributes of one object to another
If a required When is not there use a python controller (prefer sensors). E.g. transfer mouse position to an objects attribute - ONLY when the mouse was moved! - calculate character motion ONLY when a key is pressed.

Btw. there is no problem using sensors together with python controllers ;).

This is the funniest question ever.
There is not such a “Covert” button , you can only start learning py or ask someone to code and achieve what you initially wanted to.

Sorry to kick this very very old thread but I just wanted to add a different perspective to the prevailing sentiment that using Python is a bad idea. There are many reasons to not use a GUI when developing a game and they are outlined very well here (http://mikepan.com/GameEngineBook/text/07-Scripting.html#Why_Script_When_You_Can_Logic_Brick_It?) but just in case that link goes away I will reiterate the main points:

  • Sane Replacement for Large-Scale Logic-Bricked Objects
  • Better Handling of Multiple Objects
  • Access to Blender’s Advanced Features
  • Use Features That Are Not Part of Blender
  • Keep Track of Your Changes with a Version Control System
  • Debug Your Game While It Runs

Of all of these I think version control is the most important. Even from the simplest of projects you get huge benefits of being able to get back to a known working state.

Better walk 1000KM instead of grabbing an airplane. Sounds as silly.

Based on the body of the text, im pretty certain that was a mistype though.

Nobody says using python is a bad idea.

The question is more if it is a good idea to implement “everything” in python especially on a system that is not designed to work that way.