|
| 1 | +# NPC Database |
| 2 | + |
| 3 | +<div class="custom-block tip"> |
| 4 | + <p><strong>Usage:</strong> Use the search box to filter NPCs by ID, name, or region. Click on an NPC ID to copy it to clipboard.</p> |
| 5 | +</div> |
| 6 | + |
| 7 | +<div class="custom-block warning"> |
| 8 | + <p><strong>Incomplete Database:</strong> This NPC database is currently under development and does not contain all NPCs available in the game. More entries will be added in future updates.</p> |
| 9 | +</div> |
| 10 | + |
| 11 | +<script setup> |
| 12 | +import { ref, computed, onMounted } from 'vue' |
| 13 | + |
| 14 | +const npcs = ref([ |
| 15 | + { id: 'doris_lubbin', name: 'Doris Lubbin', region: 'DOWNTOWN', description: 'Local shop owner' }, |
| 16 | +]) |
| 17 | + |
| 18 | +const searchQuery = ref('') |
| 19 | +const selectedRegion = ref('ALL') |
| 20 | + |
| 21 | +const regions = computed(() => { |
| 22 | + const uniqueRegions = new Set(['ALL']) |
| 23 | + npcs.value.forEach(npc => uniqueRegions.add(npc.region)) |
| 24 | + return Array.from(uniqueRegions) |
| 25 | +}) |
| 26 | + |
| 27 | +const filteredNpcs = computed(() => { |
| 28 | + return npcs.value.filter(npc => { |
| 29 | + const matchesSearch = searchQuery.value === '' || |
| 30 | + npc.id.toLowerCase().includes(searchQuery.value.toLowerCase()) || |
| 31 | + npc.name.toLowerCase().includes(searchQuery.value.toLowerCase()) || |
| 32 | + npc.description.toLowerCase().includes(searchQuery.value.toLowerCase()) |
| 33 | + |
| 34 | + const matchesRegion = selectedRegion.value === 'ALL' || npc.region === selectedRegion.value |
| 35 | + |
| 36 | + return matchesSearch && matchesRegion |
| 37 | + }) |
| 38 | +}) |
| 39 | + |
| 40 | +const copyToClipboard = (text) => { |
| 41 | + navigator.clipboard.writeText(text) |
| 42 | + alert(`Copied: ${text}`) |
| 43 | +} |
| 44 | +</script> |
| 45 | + |
| 46 | +<div class="database-controls"> |
| 47 | + <div class="search-box"> |
| 48 | + <input |
| 49 | + v-model="searchQuery" |
| 50 | + type="text" |
| 51 | + placeholder="Search by ID, name or description..." |
| 52 | + /> |
| 53 | + </div> |
| 54 | + |
| 55 | + <div class="filter-box"> |
| 56 | + <label for="region-filter">Filter by region:</label> |
| 57 | + <select v-model="selectedRegion" id="region-filter"> |
| 58 | + <option v-for="region in regions" :key="region" :value="region"> |
| 59 | + {{ region }} |
| 60 | + </option> |
| 61 | + </select> |
| 62 | + </div> |
| 63 | +</div> |
| 64 | + |
| 65 | +<table class="database-table"> |
| 66 | + <thead> |
| 67 | + <tr> |
| 68 | + <th>NPC ID</th> |
| 69 | + <th>Name</th> |
| 70 | + <th>Region</th> |
| 71 | + <th>Description</th> |
| 72 | + </tr> |
| 73 | + </thead> |
| 74 | + <tbody> |
| 75 | + <tr v-for="npc in filteredNpcs" :key="npc.id"> |
| 76 | + <td class="id-cell" @click="copyToClipboard(npc.id)">{{ npc.id }}</td> |
| 77 | + <td>{{ npc.name }}</td> |
| 78 | + <td>{{ npc.region }}</td> |
| 79 | + <td>{{ npc.description }}</td> |
| 80 | + </tr> |
| 81 | + <tr v-if="filteredNpcs.length === 0"> |
| 82 | + <td colspan="4" class="no-results">No NPCs match your search criteria</td> |
| 83 | + </tr> |
| 84 | + </tbody> |
| 85 | +</table> |
| 86 | + |
| 87 | +## Example Usage |
| 88 | + |
| 89 | +```lua |
| 90 | +-- Get information about an NPC |
| 91 | +local npc = GetNPC("doris_lubbin") |
| 92 | + |
| 93 | +if npc then |
| 94 | + Log("Found NPC: " .. npc.FullName) |
| 95 | + Log("Current region: " .. npc.Region) |
| 96 | + |
| 97 | + -- Get NPC position |
| 98 | + local position = GetNPCPosition(npc) |
| 99 | + Log("Position: " .. position.x .. ", " .. position.y .. ", " .. position.z) |
| 100 | +end |
| 101 | + |
| 102 | +-- Check if NPC is in a specific region |
| 103 | +if IsNPCInRegion("mayor_wilson", "CITY_HALL") then |
| 104 | + Log("The mayor is at City Hall") |
| 105 | +else |
| 106 | + Log("The mayor is not at City Hall") |
| 107 | +end |
| 108 | +``` |
| 109 | + |
| 110 | +<style> |
| 111 | +.database-controls { |
| 112 | + display: flex; |
| 113 | + flex-wrap: wrap; |
| 114 | + gap: 1rem; |
| 115 | + margin-bottom: 1rem; |
| 116 | +} |
| 117 | + |
| 118 | +.search-box input { |
| 119 | + width: 300px; |
| 120 | + padding: 0.5rem; |
| 121 | + border: 1px solid var(--vp-c-divider); |
| 122 | + border-radius: 4px; |
| 123 | +} |
| 124 | + |
| 125 | +.filter-box { |
| 126 | + display: flex; |
| 127 | + align-items: center; |
| 128 | + gap: 0.5rem; |
| 129 | +} |
| 130 | + |
| 131 | +.filter-box select { |
| 132 | + padding: 0.5rem; |
| 133 | + border: 1px solid var(--vp-c-divider); |
| 134 | + border-radius: 4px; |
| 135 | + background-color: var(--vp-c-bg); |
| 136 | + color: var(--vp-c-text-1); |
| 137 | +} |
| 138 | + |
| 139 | +.database-table { |
| 140 | + width: 100%; |
| 141 | + border-collapse: collapse; |
| 142 | + margin-bottom: 2rem; |
| 143 | +} |
| 144 | + |
| 145 | +.database-table th, |
| 146 | +.database-table td { |
| 147 | + padding: 0.75rem; |
| 148 | + border: 1px solid var(--vp-c-divider); |
| 149 | + text-align: left; |
| 150 | +} |
| 151 | + |
| 152 | +.database-table th { |
| 153 | + background-color: var(--vp-c-bg-soft); |
| 154 | + font-weight: bold; |
| 155 | +} |
| 156 | + |
| 157 | +.database-table tr:nth-child(even) { |
| 158 | + background-color: var(--vp-c-bg-soft); |
| 159 | +} |
| 160 | + |
| 161 | +.id-cell { |
| 162 | + font-family: monospace; |
| 163 | + cursor: pointer; |
| 164 | + color: var(--vp-c-brand); |
| 165 | + transition: background-color 0.2s; |
| 166 | +} |
| 167 | + |
| 168 | +.id-cell:hover { |
| 169 | + background-color: var(--vp-c-brand-dimm); |
| 170 | +} |
| 171 | + |
| 172 | +.no-results { |
| 173 | + text-align: center; |
| 174 | + font-style: italic; |
| 175 | + color: var(--vp-c-text-2); |
| 176 | +} |
| 177 | +</style> |
0 commit comments