How to make a button that changes lamp energy in BGE?
scene = bge.logic.getCurrentScene()
cont = bge.logic.getCurrentController()
light = scene.lights['Lamp']

if cont.sensors['Mouse1'].hitObject.name == 'button.up' and cont.sensors['Lclick'].getButtonStatus(bge.events.LEFTMOUSE) == bge.logic.KX_INPUT_JUST_ACTIVATED:
    light.energy += 0.5

if cont.sensors['Mouse1'].hitObject.name == 'button.down' and cont.sensors['Lclick'].getButtonStatus(bge.events.LEFTMOUSE) == bge.logic.KX_INPUT_JUST_ACTIVATED:
    light.energy -= 0.5


Attach this script to your two buttons with these logic bricks. The two buttons must be named button.down and button.up, or you will have to change the names in the script.


The two buttons will increase and decrease the default Lamp energy by 0.5 per click.