added activeFunc for active obj

This commit is contained in:
Vlad committed 2026-04-11 16:18:59 +06:00
1 parent 943b6b4d21
commit bc2997d86f
7 files changed
+97 -47

No files matched your search

+14 -5
View File
@@ -174,7 +174,6 @@ namespace ZL
npcs = GameObjectLoader::loadAndCreateNpcs("resources/config2/npcs.json", CONST_ZIP_FILE);
/*
// === СТАРЫЙ КОД - ЗАКОММЕНТИРОВАНО, НПС ТЕПЕРЬ ГРУЗЯТСЯ ИЗ JSON ===
auto defaultTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/w/default_skin001.png", CONST_ZIP_FILE));
@@ -214,8 +213,6 @@ namespace ZL
npcs.push_back(std::move(npc02));
std::cout << "Load resurces step 12" << std::endl;
// === КОНЕЦ СТАРОГО КОДА ===
*/
loadingCompleted = true;
@@ -459,8 +456,20 @@ namespace ZL
std::cout << "[PICKUP] Player reached object! Distance: " << distToObject << std::endl;
std::cout << "[PICKUP] Calling Lua callback for: " << targetInteractiveObject->id << std::endl;
// Call Lua callback
scriptEngine.callItemPickupCallback(targetInteractiveObject->id);
// Call custom activate function if specified, otherwise use fallback
try {
if (!targetInteractiveObject->activateFunctionName.empty()) {
std::cout << "[PICKUP] Using custom function: " << targetInteractiveObject->activateFunctionName << std::endl;
scriptEngine.callActivateFunction(targetInteractiveObject->activateFunctionName);
}
else {
std::cout << "[PICKUP] Using fallback callback" << std::endl;
scriptEngine.callItemPickupCallback(targetInteractiveObject->id);
}
}
catch (const std::exception& e) {
std::cerr << "[PICKUP] Error calling function: " << e.what() << std::endl;
}
targetInteractiveObject = nullptr;
}