script for F-Text

Hi, I’m having trouble aligning a text with its point of origin. When you add an F-Text and choose center in the object data. in edit mode each time a letter is added, the string remains centered in relation to its point of origin. I would like to get the same thing in script. I tried with the text. center, with the modulo, with the. format, nothing does. So, if someone with the line you need to write to have the text centering as in edit mode. Sorry about my bad English, but I’m using an automatic translator

for the game

the current script:


import bge

def name(cont):

    own = cont.owner
    
    keyboard = cont.sensors["keyboard"]
    
    Text = own["Text"]
    own["Text"] = Text[:10]
    
    for key,status in keyboard.events:
        if status == bge.logic.KX_INPUT_JUST_ACTIVATED:
            string = bge.events.EventToString(key).center(10)

            if string == "BACKSPACEKEY":
                if own["Text"] > Text[:0]:
                    own["Text"] = ""

Thank you