logic brick problem

Hi,

I’ve got a problem…, how do I make a phyton logic brick onely activate when two sensors are active?, just dragging two lines to it won’t work: it will behave lake a OR controller, it activates when one of the two sensors are active, it onely need it to activate when both sensors are active…

thanks in advance,

paashaas

(is the problem clear enough?, or schould I provide you with even more details?)

uhmm Its kind of hard to answer this question, maybe your two active sensor are not really active, take a print screen, this ll make it easier for us to understand

Yes. python controller act as a or controller - but python has access to the sensors so You can check that both are active in the script.

You have to check if the sensors are positive using an if statement in the script itself, then execute your code.

To get a sensor hooked up to it requires the line mySensor = controller.sensors[‘firstSensor’], another line will be needed to get the second sensor.

Then: if mySensor.positive == True and secondSensor.positive == True:

Then place your code under the if statement and it will only execute if both are positive.

The threadDouble execution of a python controller contains an example in thread #7.

You must understand that I don’t know any python, I just copied a script for the web…

Here is a video about the problem: http://www.mediafire.com/?18hf56nyujc99i7

If I need to change the script, plz tell me exactely what to do, I’m a total nood with python…:o

btw,
here is the script

import Rasterizer
Rasterizer.showMouse(False)

thx for the replies!

all you want is showing the mouse cursor?

This is how I make the mouse show, I think its the easier way.


import bge
mouse = bge.logic.mouse
mouse.visible = True

visible = True : Show mouse
visible = False : Don’t show mouse
and for your sensors fill in the “name_of_first” and second, to whatever the names of your sensors are.


import bge                                                       # import bge functions
mouse = bge.logic.mouse                                 # setup up mouse variable for ease of use
sensor1 = controller.sensors['name_of_first_sensor_needing_to_be_active']           # first sensor
sensor2 = controller.sensors['name_of_second_sensor_needing_to_be_active']      # second sensor

if sensor1.positive == True and sensor2.positive == True: #only runs if sensors are true
        mouse.visible = True                                                             # if you want the mouse to show if the sensors are active
else:                                                                                 # else if sensors arent activated do this
        mouse.visible = False

I’m sorry, It doesn’t work…

Plz tell me what I did wrong…

What i did so far:

When you come in range of the door, it runs a show mouse script :

import Rasterizer as r
r.showMouse(1)

When mouse is over, click the button in the left corner, property one is active(the code(forgot to schow in the vid, srry,:o)) it runs the hide mouse script:

import bge

import bge functions

mouse = bge.logic.mouse

setup up mouse variable for ease of use

sensor1 = controller.sensors[‘left botton’]

first sensor

sensor2 = controller.sensors[‘over’]

second sensor

if sensor1.positive == True and sensor2.positive == True:

#only runs if sensors are true
    mouse.visible = False                                                      

a screen schot of the settings:


and the blend file: http://www.mediafire.com/?ja73cpxtik9w3m3

thanks for the replies!!

I don’t know much about Python… still learning.
But… will this work?
-create a Boolean property, name it trigger… or something
-next create your two sensors that both need to be activated. Attach them to a And Controller, and attach that to a Property Actuator.
-Make the Property Actuator a Toggle with the trigger property.
-This way… when both sensors are true, they will toggle the trigger property.
-now… make a property sensor, Evaluation type: Equal, with the trigger property, and set the value to TRUE.
-Attach that to a python sensor with your script.
-now when the trigger property is equal to TRUE, your script should run
I haven’t tested this… I’m just writing this off the top of my head.
Give it a shot though.
Good luck
M

I changed your file. It works now.

Attachments

the last sphere2.blend (896 KB)

Ok!!, thx a lot

but I will change the code panel numbers: see, a friend of me can draw really good, and he is working on some cool numbers, but thanks so much!!!, when finished, the game will probably pe posteds at kongreagate.com, I will put your name in the discription!

thx agian!