Events base.
This commit is contained in:
@ -30,11 +30,35 @@ def parseEntity(obj, chunkData):
|
||||
obj['dir'] = 'ENTITY_DIR_SOUTH'
|
||||
obj['type'] = entType
|
||||
|
||||
def getProperty(propName):
|
||||
for prop in obj['properties']:
|
||||
if prop['name'] == propName:
|
||||
return prop['value']
|
||||
return None
|
||||
|
||||
# Handle per-type properties
|
||||
if entType == 'ENTITY_TYPE_NPC':
|
||||
interactType = getProperty('interactType')
|
||||
if interactType is None:
|
||||
print(f"NPC entity missing 'interactType' property: {obj['id']}")
|
||||
sys.exit(1)
|
||||
|
||||
obj['data'] = {}
|
||||
obj['data']['npc'] = {}
|
||||
obj['data']['npc']['interactType'] = 'NPC_INTERACT_TYPE_TEXT'
|
||||
obj['data']['npc']['text'] = '"test.npc.text"'
|
||||
obj['data']['npc']['interactType'] = interactType
|
||||
|
||||
if interactType == 'NPC_INTERACT_TYPE_TEXT':
|
||||
text = getProperty('interactText')
|
||||
if text is None:
|
||||
print(f"NPC entity missing 'interactText' property: {obj['id']}")
|
||||
sys.exit(1)
|
||||
obj['data']['npc']['text'] = text
|
||||
|
||||
elif interactType == 'NPC_INTERACT_TYPE_EVENT':
|
||||
event = getProperty('interactEvent')
|
||||
if event is None:
|
||||
print(f"NPC entity missing 'interactEvent' property: {obj['id']}")
|
||||
sys.exit(1)
|
||||
obj['data']['npc']['eventData'] = f'&EVENT_{event.upper()}'
|
||||
|
||||
return obj
|
Reference in New Issue
Block a user