Hello,
I’m trying to make a simple user interface. Two buttons, Launch and Quit .
For each button a got a sensor mouse -> left button connected to one script where i am try to manage all sensors:
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
quitter = cont.sensors['SensorQuitter']
lancer = cont.sensors['SensorLancer']
if quitter.positive :
#bge.logic.endGame()
print("Quitter")
if lancer.positive :
print("lancer")
unfortunately nothing work at this time, and i don’t understand where i’m wrong .
Python script error - object 'Bouton quitter', controller 'And.002':
Traceback (most recent call last):
File "menu.py", line 10, in <module>
KeyError: 'requested item "SensorLancer" does not exist'
Is it me or are you not showing the complete code? Check line 10. Try Copying and Pasting the sensor name from the Logic Brick to Python
If that is the full code:
Why is the text editor showing wrong lines?
Maybe the console is finding the error in the wrong line.
Try connecting you menu.py script to an Always sensor.