fix: translate also walltypes

This commit is contained in:
Niklas 2023-03-16 01:56:44 +01:00
parent 212606febd
commit e31e09d589
2 changed files with 27 additions and 20 deletions

View File

@ -1,27 +1,33 @@
import json
todo_types = ["roomitemtypes", "wallitemtypes"]
# Create a dictionary mapping classname to name and description
furniture_dict = {}
with open('gamedata/furnidata.json', 'r', encoding='utf-8') as f:
furniture_data = json.load(f)
for furnitype in furniture_data['roomitemtypes']['furnitype']:
classname = furnitype['classname']
furniture_dict[classname] = {
"name": furnitype['name'],
"description": furnitype['description'],
}
for todo_type in todo_types:
for furnitype in furniture_data[todo_type]["furnitype"]:
classname = furnitype['classname']
furniture_dict[classname] = {
"name": furnitype['name'],
"description": furnitype['description'],
}
orig_furniture_data = {}
# Load the JSON file
with open('../assets/gamedata/FurnitureData.json', 'r', encoding='utf-8') as f:
furniture_data = json.load(f)
orig_furniture_data = json.load(f)
# Replace the name and description values with values from the XML file
for furnitype in furniture_data['roomitemtypes']['furnitype']:
classname = furnitype['classname']
if classname in furniture_dict:
furnitype['name'] = furniture_dict[classname]['name']
furnitype['description'] = furniture_dict[classname]['description']
for todo_type in todo_types:
for furnitype in orig_furniture_data[todo_type]["furnitype"]:
classname = furnitype['classname']
if classname in furniture_dict:
furnitype['name'] = furniture_dict[classname]['name']
furnitype['description'] = furniture_dict[classname]['description']
# Save the updated JSON file
with open('../assets/gamedata/FurnitureData.json', 'w') as f:
json.dump(furniture_data, f, separators=(',', ':'))
json.dump(orig_furniture_data, f, separators=(',', ':'))

View File

@ -1,15 +1,16 @@
import json
# Habbo Furni Translator by giu888
todo_types = ["roomitemtypes", "wallitemtypes"]
# Load the JSON data from the file
with open("../assets/gamedata/FurnitureData.json", encoding='utf-8') as f:
data = json.load(f)
with open("catalog_items.sql", "w", encoding='utf-8') as f:
for furni in data["roomitemtypes"]["furnitype"]:
furni_id = furni["id"]
if furni["name"]:
furni_name = furni["name"].replace("'", "''").strip()[:55]
f.write(f"UPDATE catalog_items SET catalog_name = '{furni_name}' WHERE item_ids = '{furni_id}';\n")
#f.write(f"UPDATE items_base SET public_name = '{furni_name}' WHERE id = '{furni_id}';\n")
for todo_type in todo_types:
for furni in data[todo_type]["furnitype"]:
furni_id = furni["id"]
if furni["name"]:
furni_name = furni["name"].replace("'", "''").strip()[:55]
f.write(f"UPDATE catalog_items SET catalog_name = '{furni_name}' WHERE item_ids = '{furni_id}';\n")
#f.write(f"UPDATE items_base SET public_name = '{furni_name}' WHERE id = '{furni_id}';\n")