KX_GameObject always returns a list. That is why our validation always results in False.
Please do not use this cryptic code as replacement. Lets look what it does:
A) “[]” -> creates a new empty list
B) “[<items>]” -> creates another new list
C) “own.children” -> puts a list into the list created with B)
D) “+” -> concatenates the list from C) with the list from A)
E) “if len(x)!=0:” -> you check if the list from D) is empty
This means you create 2 additional lists.
You place a list in another one.
You check a list to be empty. But you just filled the list with an item. This will always evaluate positive.
Better use this code:
if gameObject.children:
This evaluates positive when:
children is not None (which will never be the case)
children has at least one item (what you want to know)
Added list logic, to initiate the list, and add guns to it as picked up,
now I need to remove the Boolean values checks, and use the switch weapons script to evaluate which gun to draw.
I was thinking [ and ] would cycle through what you have, where as 1-9 would choose guns based on the index of the list, still thinking about how to achieve it.(posted a thread about it to get some help)