• H - CS: 8:00 - 16:00
  • Péntek: 8:00 - 14:00
  • Iskolavezető ügyfélfogadási idő: (Szerda) 8:00 - 16:00
  • +36-20/252-1066 +36-42/459-148
  • 4400, Nyíregyháza , Szabadság tér 12/B. IV/30. (30-as kapucsengő)

Python Library For Metin 2 -

def list_items_by_type(self, item_type: str) -> List[int]: """List all vnums with a given type.""" result = [] for vnum, entry in self.proto.entries.items(): if entry.get("type") == item_type: result.append(vnum) return result Example usage if name == " main ": # Load item proto item_proto = ProtoFile("item_proto.txt")

def save(self, path: Optional[Union[str, Path]] = None) -> None: """Save proto file back to disk.""" out_path = path or self.path with open(out_path, 'w', encoding='utf-8') as f: for entry in self.entries.values(): f.write(entry.to_line() + "\n") class QuestScript: """Simple representation of a Metin 2 quest script.""" def (self, path: Union[str, Path]): self.path = Path(path) self.content = self.path.read_text(encoding='utf-8', errors='ignore') self.blocks = self._extract_blocks()

# Find a specific item sword = item_proto.get(10) if sword: print(f"Item 10: name=sword.get('name'), price=sword.get('price')")

def replace_block(self, state: str, new_content: str) -> None: """Replace a state block.""" old_block = f"state state" if old_block in self.blocks: self.blocks[old_block] = new_content self._rebuild_content() python library for metin 2

def get_block(self, state: str) -> Optional[str]: """Get a specific state block.""" return self.blocks.get(f"state state")

def _parse(self): """Parse proto file line by line.""" with open(self.path, 'r', encoding='utf-8', errors='ignore') as f: for line in f: line = line.strip() if not line or line.startswith("#"): continue if line.startswith("vnum="): # Format: vnum=1\tname=...\ttype=... parts = line.split('\t') fields = [] vnum = None for i, part in enumerate(parts): if '=' not in part: continue key, val = part.split('=', 1) if key == "vnum": vnum = int(val) fields.append(ProtoField(key, val, i)) if vnum is not None: self.entries[vnum] = ProtoEntry(vnum, fields)

def get_item_name(self, vnum: int) -> Optional[str]: """Get localized name from item proto (assumes 'name' field).""" entry = self.proto.get(vnum) return entry.get("name") if entry else None Supports proto files (item, mob, skill, etc

def get(self, name: str) -> Optional[str]: """Get field value by name.""" for f in self.fields: if f.name == name: return f.value return None

def get(self, vnum: int) -> Optional[ProtoEntry]: """Get entry by vnum.""" return self.entries.get(vnum)

def remove(self, vnum: int) -> None: """Remove entry by vnum.""" self.entries.pop(vnum, None) Supports proto files (item

def _extract_blocks(self) -> Dict[str, str]: """Extract state/block sections.""" blocks = {} pattern = re.compile(r'(state\s+\w+)(.*?)(?=state\s+\w+|$)', re.DOTALL) for match in pattern.finditer(self.content): block_name = match.group(1).strip() block_content = match.group(2).strip() blocks[block_name] = block_content return blocks

# Use high-level manager manager = ItemManager("item_proto.txt") usable_items = manager.list_items_by_type("USE") print(f"Usable items: usable_items[:5]...")

It focuses on , modularity , and extensibility , allowing you to work with game data in Python objects instead of raw text files. 📦 metin2lib – Python Library for Metin 2 """ metin2lib - A Python library for working with Metin 2 game data files. Supports proto files (item, mob, skill, etc.), quest scripts, and more. """ import re from pathlib import Path from typing import List, Dict, Any, Optional, Union

def _rebuild_content(self): """Rebuild full script content from blocks.""" self.content = "\n\n".join([f"name\ncontent" for name, content in self.blocks.items()])