9 simple Questions about Python

Hi. im half new with Blender and creating a game. I am familiar with python basics, but i need more information, which i cant find… Please help me and answer to my questions with simple examples, ty!
I want to have everythink with ONE sensor “Allways” -> Python…

  1. How to add Object as “owner”?

import bge
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
sensor = cont.sensors[“sensor”].positive
own = cont.owner
if sensor:
scene.addObject(“Sphere”, own)

it works, but says, that script is not subscriptable. i want to find out what is the problem…
i know, that it would say no problem with the script:
scene.addObject(“Sphere”, “Cube”)
but i want Cube to spawn and have no actuator. Where is the problem here? TY

  1. How to become Message by Python?

i dont want o have the sensor “Message” and i dont want to use Bool or else… i just want simply have in my scripts somethink like:
if get.Message(“a”):
own[“prop”] += 1
what would be the example for working script? cant find anywhere… need serious help… TY

  1. How to make Delay with python?

I want just simple instead of Sensor have everythink in python, somethink like:
if own.delay(5):
own[“prop”] += 1
what would be the example for working script? cant find anywhere… need serious help… TY

  1. How to make Collision with python? somethink like:
    if collision(“OBCube”):
    own[“prop”] += 1

  2. How to make in python Mouse and MouseOver sensors? somethink like:
    if MouseOver(“OBCube”) and MouseLeftButton:
    own[“prop”] += 1

  3. How to make Random with python? I had it befor 3 years but lost and cant find a working simple example… please remind me how to do with that… and without sensor or actuator as “Int -> Uniform” example in Blender Blocks…

import Random
Rand(1, 5) // Random from 1 to 5
if Rand == 3:
own[“prop”] = 1
elif Rand ==5:
own[“prop”] = 2

  1. How to make Visibility without actuator, just in python?

if sensor:
own.Visibility = TRUE

  1. How to make motion actuator without enabled actuator, only with python? From beginning to finish?
    that should be a longer script as i remember… sadly i lost all my information cause had all in megaupload site xD

  2. Is it possible to bind python to Parented OBject? So i spawn cubes, parented with spheres, and i want that python on Cube would recognize propertie changes on spheres… it would help me ALOT on my game… somethink like:

IF parented.OBSphere[“prop”] == 1:
own[“prop”] = 2

TY all for answers… Please help me reminding the Blender Python programming, becouse i want to create my game and i need simplier, easy understanding and faster way to add new enemies or other objects and with Python, without actuators or sensors, is allways easy to find out all variables, which i need to change for new enemy… My game is like: i spawn enemy, hit him with bullets, enemy has variable health, defence, evasion, damage etc etc… (it varies how much time the game already runs, own items, variable stats etc etc…), so i have now like 30 sensors and actuators and i need to make a new enemy and its like 1 hour to add so many sensors and actuators and check which where goes, allways making much mistakes there and hard to progress… Need improve my python scripting :slight_smile:

I don’t want to be rude, but:

  1. One question at a time works better for forum threads.
  2. None of these questions have anything to do with the Python language. They are all about the BGE API. I recommend you ask at the BGE support & discussion instead.
  3. Don’t be lazy. Some of your questions are good, but some of them can easily be Googled. The one about collisions is currently discussed at the BGE forum.
  4. Learn how to use the
 tag.
5. Don't give up! As I said, I don't want to be rude, these points are just to give some good advice.

Ah, and finally: http://www.blender.org/documentation/blender_python_api_2_69_0/#game-engine-modules