Renpy Save Editor 【SIMPLE】
def save_changes(self): if not self.current_save: messagebox.showwarning("Warning", "No save file loaded") return try: # Reconstruct save data if isinstance(self.save_data, dict): if 'variables' in self.save_data: # Update variables in original structure for var_name, var_info in self.all_variables.items(): self.save_data['variables'][var_name] = var_info['value'] else: # Direct variable storage for var_name, var_info in self.all_variables.items(): self.save_data[var_name] = var_info['value'] # Save back to file backup_path = self.current_save + ".backup" import shutil shutil.copy2(self.current_save, backup_path) # Write new save file with open(self.current_save, 'wb') as f: # Write header (preserve original if possible) f.write(b'RENPYSAVE') # Compress and write data compressed = zlib.compress(json.dumps(self.save_data).encode()) f.write(compressed) self.status_var.set(f"Saved changes (backup: backup_path)") messagebox.showinfo("Success", "Save file updated successfully!") except Exception as e: messagebox.showerror("Error", f"Failed to save: str(e)") def command_line_editor(): """Command-line version for quick edits""" import sys
def on_variable_select(self, event): selection = self.variable_listbox.curselection() if not selection: return var_name = self.variable_listbox.get(selection[0]) var_info = self.all_variables.get(var_name, {}) self.var_name_label.config(text=var_name) self.var_type_label.config(text=var_info.get('type', 'unknown')) # Display value in editable text box value = var_info.get('value', '') if isinstance(value, (dict, list)): value = json.dumps(value, indent=2) else: value = str(value) self.value_entry.delete(1.0, tk.END) self.value_entry.insert(1.0, value)
def extract_variables(self): """Extract game variables from save data""" self.all_variables = {} if isinstance(self.save_data, dict): # Common Ren'Py save structure if 'variables' in self.save_data: variables_dict = self.save_data['variables'] else: variables_dict = self.save_data # Filter and categorize variables for key, value in variables_dict.items(): # Skip internal Ren'Py variables if key.startswith(('_', 'renpy', 'config')): continue var_type = type(value).__name__ self.all_variables[key] = 'value': value, 'type': var_type renpy save editor
def extract_pickle_data(self, raw_data): """Extract data from Ren'Py pickle format (simplified)""" # Real implementation would need unpickling with renpy.loader # This is a simplified version variables = {} # Look for common variable patterns in binary data # Convert to string and search for variable names text_data = raw_data.decode('latin-1', errors='ignore') # Find variable patterns like "money": 100, "name": "Player" import re patterns = [ (r'"([a-zA-Z_][a-zA-Z0-9_]*)"\s*:\s*(\d+)', 'int'), (r'"([a-zA-Z_][a-zA-Z0-9_]*)"\s*:\s*"([^"]*)"', 'str'), (r'"([a-zA-Z_][a-zA-Z0-9_]*)"\s*:\s*(true|false)', 'bool'), ] for pattern, typ in patterns: for match in re.finditer(pattern, text_data): name = match.group(1) value = match.group(2) if typ == 'bool': value = value.lower() == 'true' elif typ == 'int': value = int(value) variables[name] = value return variables
def filter_variables(self, *args): search_term = self.search_var.get().lower() self.variable_listbox.delete(0, tk.END) for var_name in sorted(self.all_variables.keys()): if search_term in var_name.lower() or not search_term: self.variable_listbox.insert(tk.END, var_name) def save_changes(self): if not self
# Convert value to appropriate type val = sys.argv[3] if val.isdigit(): val = int(val) elif val.lower() == 'true': val = True elif val.lower() == 'false': val = False
if '=' not in var_assignment: print("Invalid format. Use variable=value") sys.exit(1) '') if isinstance(value
# Navigate to variables if 'variables' in save: save['variables'][variable] = new_value else: save[variable] = new_value