0 of 0

File information

Last updated

Original upload

Created by

kleerkuro

Uploaded by

kleerkuro

Virus scan

Safe to use

Tags for this mod

2 comments

  1. Flutterschei
    Flutterschei
    • member
    • 0 kudos
    Here is a simple script for Python that multiplies all the values in a Resources.json file. It is suitable for any version of the game.
    import re
    import tkinter as tk
    from tkinter import filedialog, messagebox
    def multiply_stacking_limit():
    file_path = file_entry.get()
    multiplier_str = multiplier_entry.get()
    rounding_mode = rounding_var.get()
    ignore_units = ignore_units_var.get()  # Get the state of the checkbox
     
    if not file_path or not multiplier_str:
      messagebox.showerror("Error", "Please specify both file and multiplier!")
      return
     
    try:
      multiplier = float(multiplier_str)
    except ValueError:
      messagebox.showerror("Error", "Multiplier must be a number!")
      return
     
    try:
      # Read file as text
      with open(file_path, 'r', encoding='utf-8') as file:
    content = file.read()
      
      # Find all stackingLimit values using regex
      pattern = r'("stackingLimit"\s*:\s*)(\d+\.?\d*)'
      
      def replace_match(match):
    prefix = match.group(1)  # preserve "stackingLimit": and whitespace
    value = float(match.group(2))

    # Check if we should ignore the value of 1
    if ignore_units and value == 1:
    return match.group(0)  # Return the original match

    new_value = value * multiplier

    # Apply rounding based on selected mode
    if rounding_mode == "Round to whole":
    new_value = round(new_value)
    elif rounding_mode == "Round to 5":
    new_value = round(new_value / 5) * 5
    elif rounding_mode == "Round to 10":
    new_value = round(new_value / 10) * 10

    return f'{prefix}{int(new_value) if new_value.is_integer() else new_value}'
      
      # Replace all occurrences
      new_content = re.sub(pattern, replace_match, content)
      
      # Save only if changes were made
      if new_content != content:
    with open(file_path, 'w', encoding='utf-8') as file:
    file.write(new_content)
    messagebox.showinfo("Success", "stackingLimit values updated successfully!")
      else:
    messagebox.showwarning("Warning", "No stackingLimit values found to modify")
     
    except Exception as e:
      messagebox.showerror("Error", f"An error occurred: {str(e)}")
    def browse_file():
    filename = filedialog.askopenfilename(filetypes=[("JSON files", "*.json")])
    if filename:
      file_entry.delete(0, tk.END)
      file_entry.insert(0, filename)
    # Create GUI
    root = tk.Tk()
    root.title("JSON stackingLimit Multiplier")
    # Set window size
    window_width = 500
    window_height = 200  # Increased height for the checkbox
    # Get screen width and height
    screen_width = root.winfo_screenwidth()
    screen_height = root.winfo_screenheight()
    # Calculate x and y coordinates to center the window
    x = (screen_width // 2) - (window_width // 2)
    y = (screen_height // 2) - (window_height // 2)
    # Set the geometry of the window
    root.geometry(f"{window_width}x{window_height}+{x}+{y}")
    # Form fields
    tk.Label(root, text="JSON file:").grid(row=0, column=0, padx=5, pady=5, sticky='e')
    file_entry = tk.Entry(root, width=50)
    file_entry.grid(row=0, column=1, padx=5, pady=5)
    tk.Button(root, text="Browse...", command=browse_file).grid(row=0, column=2, padx=5, pady=5)
    tk.Label(root, text="Multiplier:").grid(row=1, column=0, padx=5, pady=5, sticky='e')
    multiplier_entry = tk.Entry(root, width=50)
    multiplier_entry.insert(0, "1.0")  # Default value
    multiplier_entry.grid(row=1, column=1, padx=5, pady=5)
    # Rounding mode
    tk.Label(root, text="Rounding mode:").grid(row=2, column=0, padx=5, pady=5, sticky='e')
    rounding_var = tk.StringVar(value="Round to whole")  # Default value
    rounding_options = ["Round to whole", "Round to 5", "Round to 10"]
    rounding_menu = tk.OptionMenu(root, rounding_var, *rounding_options)
    rounding_menu.grid(row=2, column=1, padx=5, pady=5)
    # Checkbox for ignoring units
    ignore_units_var = tk.BooleanVar()  # Variable to hold the state of the checkbox
    ignore_units_checkbox = tk.Checkbutton(root, text="Do not change stackingLimit if it is '1'", variable=ignore_units_var)
    ignore_units_checkbox.grid(row=3, column=0, columnspan=2, padx=5, pady=5)
    # Execute button
    tk.Button(root, text="Multiply stackingLimit", command=multiply_stacking_limit).grid(row=4, column=1, pady=10)
    root.mainloop()
  2. shayeryan
    shayeryan
    • member
    • 0 kudos
    After a while the game freezes after adding this .json file. As soon as all the villagers go to sleep, time freezes and you can't move the camera. As soon as I restored the original Resources.json file, everything started working normally.