selective-nested-visibility script needed

Hi Guys,

I am running BGE 2.62

I am struggling with a concept that I think only code can fix. I am trying to make a circuit readout for a game and need to simply make some cubes visible and invisible depending on which ones are already visible in any given sequence. I want to make some cubes lite up in sequence, but others need to assume there is a “back circuit” present at level 4. I have described the logic needed in the text editor in the blend file.

Any scripting help would be GREATLY appreciated.

thanks in advance! :smiley:

selective_nested_viz_01.blend (689 KB)

There are multiple options to do that.
What do you mean with depress? Do you mean pressing the button or do you mean press the button to toggle state? I assume you mean the last one.

The description of the logic is very confusing.
Try to write it in a different format.

write it down for each single cube (separately!) e.g.


depress ` --> visible,
release ` --> invisible.


depress 1 --> D2a visible 
depress ` --> D2a visible
release 1 --> D2a invisible
release ` --> D2a invisible.

depress 2 --> visible
depress ` & 1 --> ???, 
release 2 ---> invisible
release ` --> invisible

depress 3 --> visible 
depress ` & 1 & 2 --> ???
release 3 --> invisible
release 3 & 2 --> invisible 
release 3 & 2 & 1 --> invisible

I have no clue what you mean with 5…7

I know 1,2,3 are input signals (from keyboard)
You use the status of the other cubes as input too
so you need a table with this columns:

D1 (if it should become visible or invisibe)
key ’ (when they are depressed or released)
key 1
key 2
key 3

Thanks Monster. I have edited the text in the blend file to be more explicit. Please disregard the first blend file.

Thank you for looking through this. I am attaching a new blend file with new text therein.

selective_nested_viz_03.blend (694 KB)

Again, I am quite a novice in scripting.

Thanks in advance!

hmmm, it think this is just more confusing :spin:.

What I read from it is:
You have a status “lit” on each cube (which can become True/False)
And a status "visibility (which can become visible/invisible)

Dependent on the lit status the visibility should change.

lit --> visibility

I think the main problem is to express what you want in a form that it can be transformed in to logic (or code). From the nature of the problem I suggest to write a pure python module (without BGE). This can be unit tested to verify the logic is correct.

Then you need a second module that connects the model of the first module with you scene.

When writing the unit test you need to be clear what you want to achieve. Otherwise it will not be possible to write the tests.
I think I will prepare something…

This is correct. Each descendant (D2, D3, D4, D5, D6) in its OWN column needs its predecessor to be true (visible) in order for the next (lower one in its column) to be visible (true). Any break in that chain makes subsequent ones invisible. EXCEPT AT THE D4 LEVEL, … at D5 if EITHER D4a or D4d are true then either D5a or D5d (or both) can be true (visible). Additionally, if either D4b or D4e are true then D5b or D5e (or both) can be true (visible). And, if either D4c or D4f are true then D5c or D5f (or both) can be true (visible).

Hi BGE_New,

sorry but it took me a while to find a good and simple way to add your rules.
Please have a look at the attached file.

I added the rules until rule 5. You need to complete rule 5 and the following rules.
Be aware the rules are applied in the given order (1,2,3…). This means if a later rule can cancel out the decision of an earlier rule.

I added a keyboard in put to the D?a cubes. So you can lit/unlit them by keyboard. This is just for test reasons.

There is a special in the code. You get all gameObjects with the property “lit” as attribute to the module. This makes access a bit simpler:

D2a.visible = True

To check the property status, please use the function isLit(). You see it in code.


selective_nested_viz_03 (2)_simple.blend (557 KB)

Same topic different solution.
According to post #6 here is a solution that applies the rules relative.

Be aware the rules needs to be applied from d1 to d6*.

The predecessor will be determined by the object name (d3a -> d2a).

The code looks much simpler.

Again, the rules are not complete. You need to add the code for b,c,e,f and so on.

For testing the keyboard checks:
<1>…<6> for D1 …D6a
<w>,<e>,… for D2c … D6c


selective_nested_viz_03 (2)_relative.blend (558 KB)