Trying to change script string content and take effect immediately

Godot Version 4.2

Question

i have a autoload node’s script like this

func generateConstantFile():

    var script_content:String = ""
    var file:FileAccess = FileAccess.open("res://scene/BattleScene/BattleCharacterPreset/Script/BattlerInitInfoConstant.gd",FileAccess.WRITE_READ)
    var directories:Array = FileUtils.get_files_path_in_directory(rootDirectoryBattlerInitInfo)
    script_content += "enum BattlerName{\n"
    for directory:String in directories:
        script_content += "\t" + directory.get_basename().split('/')[-1] + ",\n"
    script_content += "}\n"

    file.store_string(script_content)
    file.close()
    print("generate complete")

as above,i create this script to automatically change script that already exists,and i finally aims to let other script can load the latest content within this changed script contains enum variable.here is example:

func autoGenerateCharacterNode():
    var BattlerName = ResourceLoader.load("res://scene/BattleScene/BattleCharacterPreset/Script/BattlerInitInfoConstant.gd").BattlerName
    for battlerName in BattlerName:
        # print(battlerName)
            
        var battleCharacterNode:BattleCharacterNode = BattleCharacterNodeTSCN.instantiate()
        add_child(battleCharacterNode)

        battleCharacterNode.owner = battleCharacterNode
        battleCharacterNode.setByBattlerName(BattlerName[battlerName])
        
        var pack:PackedScene = PackedScene.new()
        pack.pack(battleCharacterNode)

        var err = ResourceSaver.save(pack,defaultPackedSceneStoragePath + battlerName + ".tscn")
        if err != OK:
            print("Failed to save specialized scene file!")

        remove_child(battleCharacterNode)

it seems like this script can only get content whose version is before game launch,but not the version that changed after game launch.Could anyone give another way to help achieve my purpose?
In conclusion,i have created several scripts can update other scripts automatically so as to let my node load the latest content after game launched.(want to avoid using Dictionary,because enum variable can aplly automatic completion