how to count faces polygons during the game mode ?

are there any way to count how many polygon on my scene during the game ? i have a script to transformation my object by deleting it then replacing with another one from other layer but the problem when i get the new character i get on my screen property debug output more than one time are that mean i get more than one transformation object ?

import bge


def main():
    
    cont = bge.logic.getCurrentController()
    own = cont.owner
    scene = bge.logic.getCurrentScene()

    thestarter = own.get("onlyonetime")
    if thestarter == 0:
       own['onlyonetime'] = own.get("onlyonetime", 0) + 1
       spawner1 = scene.objects["starther"]

       transformt = scene.objectsInactive["Plane.017"]


       scene.addObject(transformt,spawner1)
       

main()

I do not see how your description is related with your question. Do you want to count faces or do you want to determine if you have an object twice in your scene?

Btw. get rid of this “main” function" it serves no other purpose than adding complexity to your code. Compare this code to the code above:


import bge


    
cont = bge.logic.getCurrentController()
own = cont.owner
scene = bge.logic.getCurrentScene()

thestarter = own.get("onlyonetime")
if thestarter == 0:
   own['onlyonetime'] = own.get("onlyonetime", 0) + 1
   spawner1 = scene.objects["starther"]

   transformt = scene.objectsInactive["Plane.017"]


   scene.addObject(transformt,spawner1)

Can you see the difference?

ps: if you want the object to execute it’s operation exactly once there are many options:

A) remove the object after finishing the operation
B) use an Always sensor (no trigger modes, no level)
C) in case you reload the scene, start the operation from a module:

onetimeRunner.py



print("Execute one time operation now")


to call it from a script:


import onetimeRunner

If you want to count the number of (active) objects:


import bge


print("Number of objects named 'Cube':", 
        len([object for object in bge.logic.getCurrentScene().objects
         if object.name == "Cube"]))