Speednut357
Premium
I've been really enjoying playing GTR2 with the weather feature. However, it takes away from the immersion when I already know what the weather is going to be like since I'm essentially the weatherman.
I have an idea, but I'm not sure how to execute it. My plan is to create several hundred weather files, number them, and store them in a specific folder. If I knew how to code, I could create a simple program that would delete the weather file from the log folder, randomly select another file, and rename it before pasting it in place.
I asked Chat GPT to help me write a short code and explain how to turn it into an exe.
I'm not sure about it, so I'm asking for some tips. Could someone please take a look?
import os
import random
import shutil
# Define the path to the game's weather file and the directory containing the weather files
game_weather_file = "/path/to/game/Weather.txt"
weather_files_directory = "/path/to/weather/files"
def replace_weather_file():
# Get a list of all weather files in the directory
weather_files = os.listdir(weather_files_directory)
# Select a random weather file from the directory
random_weather_file = random.choice(weather_files)
random_weather_file_path = os.path.join(weather_files_directory, random_weather_file)
# Replace the game's Weather.txt file
shutil.copy(random_weather_file_path, game_weather_file)
# Example usage
replace_weather_file()
I have an idea, but I'm not sure how to execute it. My plan is to create several hundred weather files, number them, and store them in a specific folder. If I knew how to code, I could create a simple program that would delete the weather file from the log folder, randomly select another file, and rename it before pasting it in place.
I asked Chat GPT to help me write a short code and explain how to turn it into an exe.
I'm not sure about it, so I'm asking for some tips. Could someone please take a look?
import os
import random
import shutil
# Define the path to the game's weather file and the directory containing the weather files
game_weather_file = "/path/to/game/Weather.txt"
weather_files_directory = "/path/to/weather/files"
def replace_weather_file():
# Get a list of all weather files in the directory
weather_files = os.listdir(weather_files_directory)
# Select a random weather file from the directory
random_weather_file = random.choice(weather_files)
random_weather_file_path = os.path.join(weather_files_directory, random_weather_file)
# Replace the game's Weather.txt file
shutil.copy(random_weather_file_path, game_weather_file)
# Example usage
replace_weather_file()