Option menu

Okay i posted a while back asking how could i turn the GLSL, shaders, lights etc.
off in real time, let`s say for a option menu, how can i do this ??

################  enable/disable the glsl material settings

# import bge module
import bge

# get the render module
rend = bge.render

# enable GLSL lights enabled
rend.setGLSLMaterialSetting("lights", 0)

# disable GLSL shaders 
rend.setGLSLMaterialSetting("shaders", 0)

This works, however when add the following it does not work in real time
I add a bolean with string name (lights) false
Then let`s say keyboard (L) and (Prop) lights = true

Also let`s say i do this on another scene (overlay) how can i make it effect
the GameScene ?

What effect are you trying to achieve with turning off the lights? Is it to make the menu more visible or is it as a performance setting?
Either way i’d reccomend turning off the light rather than disabling the effect of the light.

The string need to start with a uppercase, if I remember correctly…

EDIT: Nope, I was wrong, apparently, your script work correctly, try dowloading a version of blender from the buildbot, about what a say before of the uppercase, I remember the first time I tried use the setGLSLMaterialSetting i try it and it worked, or maybe it was the reverse.

Yeah, i want a bunch of options like

I mean this is pretty basic stuff, somebody must have code or know how to do it aha.

Can you explain a bit more about how it works? You mentioned it worked, but not in real time. Does it take effect when you restart the simulation? Or when you change scene? Or just the scene the code is activated on? Does it persist if you change scene?

Okay it`s like this
The boolean string does not work, if you go into python and choose boolean on and off
then it works when you click P, but if you have a keyboard command in BGE to toggle
between On/Off it does not work.

Can you upload a blend to demonstrate? If you can change it with Python successfully then I don’t see any reason why you couldn’t plug a keyboard sensor into a very similar script and achieve the same results.

It’s worth checking that you’re putting in the right type of variable. For example:
1 (the integer) is not the same as “1” (the string)
1 is the same as True
0 is the same as False
“1” can be evaluated as True, but is not the same. (note: any string that isn’t empty is considered True)
“0” can be evaluated as True as well, because it’s not an empty string

your sample works for me. This is what I used for testing:

import bge

def switchOffLights():
    bge.render.setGLSLMaterialSetting("lights", 0)

It works perfectly fine regardless the sensor. The description of your symptom (post #5) sounds like you have some other problems that prevent the code from being executed.

BTW: I noticed, that this command changes the settings of Blender as well (means the flag is disabled after exiting the BGE). To me this looks like a bad bug. It would not matter with blenderplayer, but could be very disturbing when developing.

It is not the same, it is interpreted as equal. (It can’t be the same as it is a different type (bool vs. int)

simple test:

def printComparisation():
  printCompare( 1, "1")
  printCompare( 1, True)
  printCompare( 0, False)
  printCompare( "1", True)
  printCompare( "0", True)
  printCompare( "", False)
  printCompare( "1", "1")

def printCompare(a,b):
  print( formatIs(a, b) )
  print( formatEquals(a, b))
def formatIs(a, b):
   return "{}   is   {}	: {}".format( a, b, a is b)

def formatEquals(a, b):
   return "{} equals {}	: {}".format( a, b, a == b)

I got:

Blender Game Engine Started
1   is   1      : False
1 equals 1      : False
1   is   True   : False
1 equals True   : True
0   is   False  : False
0 equals False  : True
1   is   True   : False
1 equals True   : False
0   is   True   : False
0 equals True   : False
   is   False   : False
 equals False   : False
1   is   1      : True
1 equals 1      : True
Blender Game Engine Finished

Cheers monster,
The question is now, how i can i change it in real time since logic bricks don`t work, if they do
can somebody show me.