|
| 1 | +# Examples |
| 2 | + |
| 3 | +This directory would contain example Godot projects demonstrating how to use ltk-godot. |
| 4 | + |
| 5 | +## Basic Usage Example |
| 6 | + |
| 7 | +Here's a simple example of using the extension in GDScript: |
| 8 | + |
| 9 | +```gdscript |
| 10 | +extends Node |
| 11 | +
|
| 12 | +func _ready(): |
| 13 | + # Load a WAD archive |
| 14 | + var wad = WadLoader.new() |
| 15 | + if wad.load("res://assets/league/Data.wad"): |
| 16 | + print("WAD loaded successfully!") |
| 17 | + print("Entry count: ", wad.get_entry_count()) |
| 18 | + |
| 19 | + # Load a mesh |
| 20 | + var mesh = MeshLoader.new() |
| 21 | + if mesh.load("res://assets/league/model.skn"): |
| 22 | + print("Mesh loaded successfully!") |
| 23 | + print("Vertices: ", mesh.get_vertex_count()) |
| 24 | + var bounds = mesh.get_bounds() |
| 25 | + print("Bounds min: ", bounds["min"]) |
| 26 | + print("Bounds max: ", bounds["max"]) |
| 27 | + |
| 28 | + # Load a texture |
| 29 | + var texture = TextureLoader.new() |
| 30 | + if texture.load("res://assets/league/texture.dds"): |
| 31 | + print("Texture loaded successfully!") |
| 32 | + print("Dimensions: ", texture.get_dimensions()) |
| 33 | +``` |
| 34 | + |
| 35 | +## Integration Example |
| 36 | + |
| 37 | +Project structure when using ltk-godot: |
| 38 | + |
| 39 | +``` |
| 40 | +my_godot_project/ |
| 41 | +├── addons/ |
| 42 | +│ └── ltk-godot/ |
| 43 | +│ ├── ltk_godot.gdextension |
| 44 | +│ ├── target/ |
| 45 | +│ │ ├── debug/ |
| 46 | +│ │ │ └── libltk_godot.so |
| 47 | +│ │ └── release/ |
| 48 | +│ │ └── libltk_godot.so |
| 49 | +│ └── ... |
| 50 | +├── assets/ |
| 51 | +│ └── league/ |
| 52 | +│ ├── Data.wad |
| 53 | +│ ├── model.skn |
| 54 | +│ └── texture.dds |
| 55 | +├── scenes/ |
| 56 | +│ └── main.tscn |
| 57 | +└── project.godot |
| 58 | +``` |
| 59 | + |
| 60 | +## Advanced Usage |
| 61 | + |
| 62 | +### Custom Resource Loader |
| 63 | + |
| 64 | +You can create custom resource loaders that use ltk-godot to automatically import League of Legends assets: |
| 65 | + |
| 66 | +```gdscript |
| 67 | +@tool |
| 68 | +extends EditorImportPlugin |
| 69 | +
|
| 70 | +func _get_importer_name(): |
| 71 | + return "league.mesh" |
| 72 | +
|
| 73 | +func _get_visible_name(): |
| 74 | + return "League Mesh" |
| 75 | +
|
| 76 | +func _get_recognized_extensions(): |
| 77 | + return ["skn", "scb", "sco"] |
| 78 | +
|
| 79 | +func _get_resource_type(): |
| 80 | + return "Mesh" |
| 81 | +
|
| 82 | +func _import(source_file, save_path, options, r_platform_variants, r_gen_files): |
| 83 | + var loader = MeshLoader.new() |
| 84 | + if loader.load(source_file): |
| 85 | + # Convert to Godot mesh format |
| 86 | + # Save as .res or .tres |
| 87 | + return OK |
| 88 | + return FAILED |
| 89 | +``` |
| 90 | + |
| 91 | +This allows you to drag-and-drop League of Legends files directly into your Godot project! |
0 commit comments