with open(save_path, 'wb') as f: f.write(b'RENPYSAVE') f.write(zlib.compress(json.dumps(save).encode()))
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
# Navigate to variables if 'variables' in save: save['variables'][variable] = new_value else: save[variable] = new_value renpy save editor
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
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) with open(save_path, 'wb') as f: f
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
# Parse value try: if var_value.isdigit(): var_value = int(var_value) elif var_value.lower() in ('true', 'false'): var_value = var_value.lower() == 'true' except: pass ] for pattern
if len(sys.argv) > 1 and sys.argv[1] == '--cli': command_line_editor() else: root = tk.Tk() app = RenPySaveEditor(root) root.mainloop() # quick_edit.py - Simple command-line editor import json import zlib import sys def edit_save(save_path, variable, new_value): with open(save_path, 'rb') as f: f.read(8) # Skip header data = zlib.decompress(f.read()) save = json.loads(data)
def update_variable(self): selection = self.variable_listbox.curselection() if not selection: messagebox.showwarning("Warning", "No variable selected") return var_name = self.variable_listbox.get(selection[0]) new_value_str = self.value_entry.get(1.0, tk.END).strip() current_type = self.all_variables[var_name]['type'] try: # Convert value based on type if current_type == 'int': new_value = int(new_value_str) elif current_type == 'float': new_value = float(new_value_str) elif current_type == 'bool': new_value = new_value_str.lower() in ('true', '1', 'yes', 'on') elif current_type == 'list': new_value = json.loads(new_value_str) elif current_type == 'dict': new_value = json.loads(new_value_str) else: new_value = new_value_str # Update variable self.all_variables[var_name]['value'] = new_value self.status_var.set(f"Updated var_name = new_value") except Exception as e: messagebox.showerror("Error", f"Failed to convert value: str(e)")