Cursos Ensino da Linguagem renpy save editor

Renpy Save Editor ✦

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

# Load and edit save editor = RenPySaveEditor(None) editor.current_save = save_file editor.load_save_data()

save_file = sys.argv[1] var_assignment = sys.argv[2] renpy save editor

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)

if var_name in editor.all_variables: editor.all_variables[var_name]['value'] = var_value editor.save_changes() print(f"Updated var_name to var_value") else: print(f"Variable 'var_name' not found in save") if == " main ": import sys

# Navigate to variables if 'variables' in save: save['variables'][variable] = new_value else: save[variable] = new_value def on_variable_select(self, event): selection = self

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

with open(save_path, 'wb') as f: f.write(b'RENPYSAVE') f.write(zlib.compress(json.dumps(save).encode()))

if len(sys.argv) < 3: print("Usage: python renpy_save_editor.py <savefile> <variable>=<value>") print("Example: python renpy_save_editor.py 1-1-LT1.save money=9999") sys.exit(1) '') if isinstance(value

def load_save_data(self): """Parse Ren'Py save file format""" with open(self.current_save, 'rb') as f: # Read header (Ren'Py version and metadata) header = f.read(8) # Check if it's compressed (usually zlib compressed JSON) try: # Attempt to decompress data = zlib.decompress(f.read()) self.save_data = json.loads(data) except: # Might be uncompressed or different format f.seek(8) data = f.read() try: self.save_data = json.loads(data) except: # Try to extract from pickle (advanced) self.save_data = self.extract_pickle_data(data) # Extract variables from the save structure self.extract_variables()

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)")

class RenPySaveEditor: def (self, root): self.root = root self.root.title("Ren'Py Save Editor v1.0") self.root.geometry("900x600")

Utilizamos cookies para melhorar nossos serviços.
Se continuar navegando, aceita o seu uso.
Ver mais  |