NPC full circle.

This commit is contained in:
2025-06-23 23:33:52 -05:00
parent 57d231b561
commit 5520945022
2 changed files with 26 additions and 23 deletions

View File

@ -14,6 +14,8 @@ void npcLoad(entity_t *entity, const entity_t *source) {
assertNotNull(entity, "Entity pointer cannot be NULL");
assertNotNull(source, "Source entity pointer cannot be NULL");
assertTrue(source->type == ENTITY_TYPE_NPC, "Source entity type must be NPC");
entity->npc = source->npc;
}
void npcUpdate(entity_t *entity) {
@ -28,6 +30,7 @@ void npcInteract(entity_t *player, entity_t *self) {
break;
case NPC_INTERACT_TYPE_TEXT:
uiTextboxSetText(languageGet(self->npc.text));
break;
case NPC_INTERACT_TYPE_CONVO:
@ -46,29 +49,29 @@ void npcInteract(entity_t *player, entity_t *self) {
// "of Darth Plagueis the Wise? He was a dark lord of the Sith, "
// "so powerful and so wise he could use the Force to influence the midichlorians"
// );
const char_t *name = "Dom";
const char_t *key = "name";
uint16_t len = languageFormat(
"test.npc.text",
NULL,
0,
(const char_t *[]){ key },
(const char_t *[]){ name },
1
);
// const char_t *name = "Dom";
// const char_t *key = "name";
// uint16_t len = languageFormat(
// "test.npc.text",
// NULL,
// 0,
// (const char_t *[]){ key },
// (const char_t *[]){ name },
// 1
// );
char_t *buffer = malloc(sizeof(char_t) + len + 1);
assertNotNull(buffer, "Failed to allocate buffer for NPC text");
// char_t *buffer = malloc(sizeof(char_t) + len + 1);
// assertNotNull(buffer, "Failed to allocate buffer for NPC text");
languageFormat(
"test.npc.text",
buffer,
len + 1,
(const char_t *[]){ key },
(const char_t *[]){ name },
1
);
// languageFormat(
// "test.npc.text",
// buffer,
// len + 1,
// (const char_t *[]){ key },
// (const char_t *[]){ name },
// 1
// );
uiTextboxSetText(buffer);
free(buffer);
// uiTextboxSetText(buffer);
// free(buffer);
}

View File

@ -35,6 +35,6 @@ def parseEntity(obj, chunkData):
obj['data'] = {}
obj['data']['npc'] = {}
obj['data']['npc']['interactType'] = 'NPC_INTERACT_TYPE_TEXT'
obj['data']['npc']['text'] = '"test"'
obj['data']['npc']['text'] = '"test.npc.text"'
return obj