### Load OSRS Interface Definitions and Components (Python) Source: https://context7.com/danaedf/osrs-data/llms.txt Loads OSRS interface definitions and individual component data from cached JSON files. It handles loading entire interfaces by ID and specific components within an interface by their IDs. The functions return None if the requested files do not exist. Dependencies include the 'json' and 'os' Python libraries. ```python import json import os def load_interface(interface_id): """Load interface definition""" file_path = f'./cache/dumps/interfaces/{interface_id}.json' if os.path.exists(file_path): with open(file_path, 'r') as f: return json.load(f) return None def load_interface_component(interface_id, component_id): """Load specific interface component""" file_path = f'./cache/dumps/interfaces/{interface_id}/{component_id}.json' if os.path.exists(file_path): with open(file_path, 'r') as f: return json.load(f) return None # Load interface interface = load_interface(10) if interface: print(f"Interface ID: {interface['id']}") print(f"Type: {interface.get('type', 'Unknown')}") print(f"Components: {len(interface.get('components', []))}") # Load specific component component = load_interface_component(10, 5) if component: print(f"\nComponent ID: {component['id']}") print(f"Parent ID: {component.get('parentId', -1)}") print(f"Position: ({component.get('x', 0)}, {component.get('y', 0)})") print(f"Size: {component.get('width', 0)}x{component.get('height', 0)}") print(f"Visible: {component.get('isHidden', False)}") # Interaction properties if 'actions' in component: actions = [a for a in component['actions'] if a] print(f"Actions: {', '.join(actions)}") # List all interfaces def list_all_interfaces(): """List all available interfaces""" interfaces = [] for entry in os.listdir('./cache/dumps/interfaces'): if os.path.isdir(f'./cache/dumps/interfaces/{entry}'): interfaces.append(int(entry)) return sorted(interfaces) all_interfaces = list_all_interfaces() print(f"\nTotal Interfaces: {len(all_interfaces)}") print(f"Interface IDs: {all_interfaces[:20]}...") ``` -------------------------------- ### Load Item Definitions (Python) Source: https://context7.com/danaedf/osrs-data/llms.txt Loads item definitions from the game cache in JSON format. This function uses Python's built-in 'json' module and handles 'FileNotFoundError'. It accepts an item ID and returns the item's data, including inventory models, equipment properties, tradeable status, and interface options, or None if the item is not found. It also prints various item attributes. ```python import json def load_item(item_id): """Load item definition from cache""" try: with open(f'./cache/dumps/items/{item_id}.json', 'r') as f: return json.load(f) except FileNotFoundError: print(f"Item {item_id} not found") return None # Load item data toolkit = load_item(1) if toolkit: print(f"Item ID: {toolkit['id']}") print(f"Name: {toolkit['name']}") print(f"Examine Text: {toolkit['examine']}") print(f"Members Only: {toolkit['members']}") print(f"Tradeable: {toolkit['isTradeable']}") print(f"Stackable: {toolkit['stackable']}") print(f"Cost: {toolkit['cost']} coins") print(f"Weight: {toolkit['weight']} grams") # Inventory model and rendering print(f"Inventory Model: {toolkit['inventoryModel']}") print(f"Zoom 2D: {toolkit['zoom2d']}") print(f"X/Y/Z Angles: {toolkit['xan2d']}/{toolkit['yan2d']}/{toolkit['zan2d']}") # Interaction options (right-click menu) ground_options = [opt for opt in toolkit['options'] if opt] inventory_options = [opt for opt in toolkit['interfaceOptions'] if opt] print(f"Ground Options: {', '.join(ground_options)}") print(f"Inventory Options: {', '.join(inventory_options)}") # Equipment slots if toolkit['maleModel0'] != -1: print(f"Equippable - Male Model: {toolkit['maleModel0']}") if toolkit['femaleModel0'] != -1: print(f"Equippable - Female Model: {toolkit['femaleModel0']}") # Noted/placeholder items if toolkit['notedID'] != -1: print(f"Noted Version ID: {toolkit['notedID']}") if toolkit['placeholderId'] != -1: print(f"Placeholder ID: {toolkit['placeholderId']}") # Output: # Item ID: 1 # Name: Toolkit # Examine Text: Good for repairing broken cannons. # Members Only: True # Tradeable: False # Stackable: 0 # Cost: 1 coins # Weight: 453 grams # Inventory Model: 2679 # Zoom 2D: 1164 # X/Y/Z Angles: 477/2026/0 # Ground Options: Take # Inventory Options: Destroy # Placeholder ID: 17852 ``` -------------------------------- ### Load OSRS Game Cache DB Index and Table Definitions (JavaScript) Source: https://context7.com/danaedf/osrs-data/llms.txt Loads database index structures and table definitions from the game cache using provided table IDs. It reads JSON files from a local cache directory. Errors during file reading or JSON parsing will result in a null return value. ```javascript const fs = require('fs'); function loadDBIndex(tableId) { const indexPath = `./cache/dumps/dbindex/${tableId}.json`; try { return JSON.parse(fs.readFileSync(indexPath, 'utf8')); } catch (error) { return null; } } function loadDBTable(tableId) { const tablePath = `./cache/dumps/dbtable/${tableId}.json`; try { return JSON.parse(fs.readFileSync(tablePath, 'utf8')); } catch (error) { return null; } } // Load database index const dbIndex = loadDBIndex(0); if (dbIndex) { console.log(`Table ID: ${dbIndex.tableId}`); console.log(`Column ID: ${dbIndex.columnId}`); console.log(`Tuple Types: ${dbIndex.tupleTypes.join(', ')}`); // Process tuple indexes const firstIndex = dbIndex.tupleIndexes[0]; const indexKeys = Object.keys(firstIndex); console.log(`Index Keys: ${indexKeys.join(', ')}`); indexKeys.forEach(key => { const values = firstIndex[key]; console.log(`Index ${key}: ${values.length} entries`); console.log(`Sample values: ${values.slice(0, 10).join(', ')}...`); }); } // Load database table definition const dbTable = loadDBTable(0); if (dbTable) { console.log(`\nTable Structure:`); console.log(JSON.stringify(dbTable, null, 2)); } ``` -------------------------------- ### Load NPC Definitions (JavaScript) Source: https://context7.com/danaedf/osrs-data/llms.txt Loads NPC definitions from the game cache in JSON format. This function requires the 'fs' module for file system access. It takes an NPC ID as input and returns the NPC's data object, including models, animations, actions, and rendering parameters, or null if the NPC is not found. Includes extensive logging for NPC attributes. ```javascript // Example: Reading NPC cache data const fs = require('fs'); function loadNPC(npcId) { try { const npcData = JSON.parse(fs.readFileSync(`./cache/dumps/npcs/${npcId}.json`, 'utf8')); return npcData; } catch (error) { console.error(`NPC ${npcId} not found`); return null; } } // Load and analyze NPC const molanisk = loadNPC(1); if (molanisk) { console.log(`NPC ID: ${molanisk.id}`); console.log(`Name: ${molanisk.name}`); console.log(`Size: ${molanisk.size}`); console.log(`Combat Level: ${molanisk.combatLevel}`); // Animation IDs console.log(`Standing Animation: ${molanisk.standingAnimation}`); console.log(`Walking Animation: ${molanisk.walkingAnimation}`); console.log(`Run Animation: ${molanisk.runAnimation}`); // Interaction options console.log(`Actions: ${molanisk.actions.filter(a => a !== null).join(', ')}`); console.log(`Is Interactable: ${molanisk.isInteractable}`); console.log(`Visible on Minimap: ${molanisk.isMinimapVisible}`); // Rendering properties console.log(`Width Scale: ${molanisk.widthScale}`); console.log(`Height Scale: ${molanisk.heightScale}`); console.log(`Rotation Speed: ${molanisk.rotationSpeed}`); // Stats [Attack, Defence, Strength, Hitpoints, Ranged, Magic] console.log(`Stats: ${JSON.stringify(molanisk.stats)}`); console.log(`Model IDs: ${molanisk.models.join(', ')}`); } // Output: // NPC ID: 1 // Name: Molanisk // Size: 1 // Combat Level: 51 // Standing Animation: 6010 // Walking Animation: 6011 // Run Animation: -1 // Actions: Attack // Is Interactable: true // Visible on Minimap: true // Width Scale: 128 // Height Scale: 128 // Rotation Speed: 32 // Stats: [40,50,40,52,1,0] // Model IDs: 23855 ``` -------------------------------- ### Access Complete Monster Data (JavaScript) Source: https://context7.com/danaedf/osrs-data/llms.txt Reads and parses a complete monster data JSON file to access detailed combat stats, slayer requirements, drops, and defensive bonuses for OSRS monsters. Requires Node.js environment with 'fs' module. ```javascript // Example: Reading complete monster data const fs = require('fs'); const monsters = JSON.parse(fs.readFileSync('./monsters/monsters-complete.json', 'utf8')); // Access specific monster by ID const molanisk = monsters["1"]; console.log(`Name: ${molanisk.name}`); console.log(`Combat Level: ${molanisk.combatLevel}`); console.log(`Hitpoints: ${molanisk.hitpoints}`); console.log(`Slayer Level Required: ${molanisk.slayerLevel}`); console.log(`Slayer XP: ${molanisk.slayerXp}`); // Check attack types console.log(`Attack Types: ${molanisk.attackTypes.join(', ')}`); console.log(`Attack Speed: ${molanisk.attackSpeed}`); console.log(`Max Hit: ${molanisk.maxHit}`); // Defensive stats console.log(`Defence Stab: ${molanisk.defenceStab}`); console.log(`Defence Slash: ${molanisk.defenceSlash}`); console.log(`Defence Crush: ${molanisk.defenceCrush}`); console.log(`Defence Magic: ${molanisk.defenceMagic}`); console.log(`Defence Ranged: ${molanisk.defenceRanged}`); // Process drops molanisk.drops.forEach(drop => { console.log(`Drop: ${drop.name}, Qty: ${drop.quantityLow}-${drop.quantityHigh}, Rarity: ${(drop.rarity * 100).toFixed(2)}%`); }); // Output: // Name: Molanisk // Combat Level: 51 // Hitpoints: 52 // Slayer Level Required: 39 // Slayer XP: 52.0 // Attack Types: crush // Attack Speed: 4 // Max Hit: 5 // Defence Stab: 45 // Defence Slash: 45 // Defence Crush: 35 // Defence Magic: 30 // Defence Ranged: 55 // Drop: Bones, Qty: 1-1, Rarity: 100.00% // Drop: Grimy harralander, Qty: 1-1, Rarity: 2.73% // ... ``` -------------------------------- ### Load and Filter Monster Data (Python) Source: https://context7.com/danaedf/osrs-data/llms.txt Provides functions to load individual monster data by ID from JSON files and to filter slayer monsters within a specified level range. Utilizes Python's 'json' and 'os' modules. ```python import json import os def load_monster(monster_id): """Load monster data by ID""" file_path = f'./monsters/monsters-json/{monster_id}.json' if os.path.exists(file_path): with open(file_path, 'r') as f: return json.load(f) return None # Load specific monsters goblin = load_monster(1024) if goblin: print(f"Monster: {goblin['name']}") print(f"Members Only: {goblin['members']}") print(f"Aggressive: {goblin['aggressive']}") print(f"Poisonous: {goblin['poisonous']}") print(f"Venomous: {goblin['venomous']}") # Check if it's a slayer monster if goblin.get('slayerMonster'): print(f"Slayer Masters: {', '.join(goblin['slayerMasters'])}") # Filter monsters by criteria def find_slayer_monsters(min_level, max_level): """Find all slayer monsters within level range""" monsters = [] for filename in os.listdir('./monsters/monsters-json'): with open(f'./monsters/monsters-json/{filename}', 'r') as f: monster = json.load(f) if (monster.get('slayerMonster') and min_level <= monster.get('slayerLevel', 0) <= max_level): monsters.append(monster) return monsters # Find slayer monsters between level 30-50 mid_level_slayer = find_slayer_monsters(30, 50) print(f"\nFound {len(mid_level_slayer)} slayer monsters between level 30-50") ``` -------------------------------- ### Access OSRS Game Cache DB Rows Data (Python) Source: https://context7.com/danaedf/osrs-data/llms.txt Accesses database row data from the game cache, allowing retrieval of specific rows by ID or querying all rows for a given table ID. It handles file operations and JSON parsing, returning None if a file is not found or an error occurs. Includes basic analysis of table structure. ```python import json import os def load_db_rows(row_id): """Load database row data""" file_path = f'./cache/dumps/dbrows/{row_id}.json' if os.path.exists(file_path): with open(file_path, 'r') as f: return json.load(f) return None def query_db_rows_by_table(table_id): """Query all rows for a specific table""" rows = [] for filename in os.listdir('./cache/dumps/dbrows'): if filename.endswith('.json'): with open(f'./cache/dumps/dbrows/{filename}', 'r') as f: row_data = json.load(f) if row_data.get('tableId') == table_id: rows.append(row_data) return rows # Load specific row row = load_db_rows(0) if row: print(f"Table ID: {row['tableId']}") print(f"Column ID: {row['columnId']}") print(f"Tuple ID: {row['tupleId']}") print(f"Fields: {row['fields']}") # Process field values for i, (field_type, value) in enumerate(zip(row['fields'], row['values'])): print(f"Field {i} ({field_type}): {value}") # Query all rows from a table table_rows = query_db_rows_by_table(0) print(f"\nFound {len(table_rows)} rows in table 0") # Aggregate data analysis def analyze_table_structure(table_id): """Analyze structure of database table""" rows = query_db_rows_by_table(table_id) field_types = {} for row in rows: for field_type in row.get('fields', []): field_types[field_type] = field_types.get(field_type, 0) + 1 print(f"\nTable {table_id} Analysis:") print(f"Total Rows: {len(rows)}") print(f"Field Type Distribution:") for field_type, count in field_types.items(): print(f" {field_type}: {count} occurrences") analyze_table_structure(0) ``` -------------------------------- ### Load OSRS Game Enums (JavaScript) Source: https://context7.com/danaedf/osrs-data/llms.txt Loads game enums, which are collections of named values used throughout the game, from JSON files in the cache. It handles file reading and JSON parsing, returning null if the enum file is not found or invalid. The function also includes logic to find enums based on their value type. ```javascript const fs = require('fs'); function loadEnum(enumId) { try { return JSON.parse(fs.readFileSync(`./cache/dumps/enums/${enumId}.json`, 'utf8')); } catch (error) { return null; } } // Load and process enum const gameEnum = loadEnum(100); if (gameEnum) { console.log(`Enum ID: ${gameEnum.id}`); console.log(`Key Type: ${gameEnum.keyType}`); console.log(`Value Type: ${gameEnum.valueType}`); console.log(`Default Value: ${gameEnum.defaultValue}`); console.log(`Size: ${gameEnum.size}`); // Process key-value pairs console.log('\nEnum Values:'); const keys = Object.keys(gameEnum.values); keys.forEach(key => { console.log(` ${key} => ${gameEnum.values[key]}`); }); } // Find enums by type function findEnumsByValueType(valueType) { const enums = []; const files = fs.readdirSync('./cache/dumps/enums'); files.forEach(file => { const enumData = JSON.parse(fs.readFileSync(`./cache/dumps/enums/${file}`, 'utf8')); if (enumData.valueType === valueType) { enums.push(enumData); } }); return enums; } // Find all string-valued enums const stringEnums = findEnumsByValueType('STRING'); console.log(`\nFound ${stringEnums.length} enums with STRING values`); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.