22 lines
1.3 KiB
Python
22 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Rewrite the OctoShop model-preview display list (sourceCreatureDisplays in
|
|
ops/native_source_store_secure.lua) from the server catalogue and the client data.
|
|
|
|
A shop card shows a 3D creature preview only for displays the client actually has, so the
|
|
list is every tw_world.shop_items.model_id that exists in the installed CreatureDisplayInfo.
|
|
Usage: shop_creature_displays.py <has.txt from Db2Bake 'has' over all shop model_ids>
|
|
(rows '<id> present ...' / '<id> ABSENT'). Prints counts; edits the Lua file in place.
|
|
"""
|
|
import re, sys
|
|
from pathlib import Path
|
|
LUA = Path(__file__).resolve().parent / 'native_source_store_secure.lua'
|
|
present = sorted({int(l.split()[0]) for l in open(sys.argv[1]) if ' present' in l})
|
|
absent = sorted({int(l.split()[0]) for l in open(sys.argv[1]) if l.strip().endswith('ABSENT')})
|
|
s = LUA.read_text()
|
|
head = '-- Explicit CreatureDisplayInfo membership in accepted current package; native IDs retained.\nlocal sourceCreatureDisplays = {\n'
|
|
a = s.index(head) + len(head); b = s.index('}\n', a)
|
|
s = s[:a] + ''.join(f' [{i}]=true,\n' for i in present) + s[b:]
|
|
s = s.replace(head, '-- Every shop model_id present in the installed CreatureDisplayInfo (ops/shop_creature_displays.py).\nlocal sourceCreatureDisplays = {\n')
|
|
LUA.write_text(s)
|
|
print('preview displays', len(present), 'absent (icon only)', absent)
|