Fixing logger and windows version - remove terminal

This commit is contained in:
Vladislav Khorev committed 2026-07-14 20:39:41 +03:00
1 parent 76287dda46
commit a7d17d9afd
27 files changed
+349 -243

No files matched your search

+19 -19
View File
@@ -124,14 +124,14 @@ namespace ZL {
}
const float rad = angle * static_cast<float>(M_PI) / 180.f;
std::cout << "[script] npc_rotate_to: index " << index << " angle " << angle << " degrees (" << rad << " radians)" << std::endl;
logger() << "[script] npc_rotate_to: index " << index << " angle " << angle << " degrees (" << rad << " radians)" << std::endl;
npcs[index]->state.targetFacingAngle = rad;
});
api.set_function("player_rotate_to",
[loc](float angle) {
const float rad = angle * static_cast<float>(M_PI) / 180.f;
std::cout << "[script] player_rotate_to: angle " << angle << " degrees (" << rad << " radians)" << std::endl;
logger() << "[script] player_rotate_to: angle " << angle << " degrees (" << rad << " radians)" << std::endl;
loc->player->state.targetFacingAngle = rad;
});
@@ -172,12 +172,12 @@ namespace ZL {
const Item* item = ItemRegistry::instance().findById(itemId);
if (item) {
if (inventory->hasItem(itemId)) {
std::cout << "[script] has_item: " << item->name << " returns true" << std::endl;
logger() << "[script] has_item: " << item->name << " returns true" << std::endl;
return true;
}
else
{
std::cout << "[script] has_item: " << item->name << " returns false" << std::endl;
logger() << "[script] has_item: " << item->name << " returns false" << std::endl;
return false;
}
}
@@ -192,7 +192,7 @@ namespace ZL {
const Item* item = ItemRegistry::instance().findById(itemId);
if (item) {
inventory->addItem(item->id);
std::cout << "[script] pickup_item: " << item->name << std::endl;
logger() << "[script] pickup_item: " << item->name << std::endl;
} else {
std::cerr << "[script] pickup_item: item '" << itemId << "' not found in ItemRegistry\n";
}
@@ -200,7 +200,7 @@ namespace ZL {
// remove_item(item_id)
api.set_function("remove_item", [loc, inventory](const std::string& id) {
std::cout << "[script] remove_item: " << id << std::endl;
logger() << "[script] remove_item: " << id << std::endl;
inventory->removeItem(id);
});
@@ -209,7 +209,7 @@ namespace ZL {
for (auto& intObj : loc->interactiveObjects) {
if (intObj.loadedObject.name == objectName) {
intObj.state.isActive = false;
std::cout << "[script] deactivate_interactive_object: " << objectName << std::endl;
logger() << "[script] deactivate_interactive_object: " << objectName << std::endl;
return;
}
}
@@ -221,7 +221,7 @@ namespace ZL {
for (auto& intObj : loc->interactiveObjects) {
if (intObj.loadedObject.name == objectName) {
intObj.state.isActive = true;
std::cout << "[script] activate_interactive_object: " << objectName << std::endl;
logger() << "[script] activate_interactive_object: " << objectName << std::endl;
return;
}
}
@@ -232,7 +232,7 @@ namespace ZL {
for (auto& intObj : loc->interactiveObjects) {
if (intObj.loadedObject.name == objectName) {
intObj.state.rotationY = value * static_cast<float>(M_PI) / 180.f;
std::cout << "[script] set_object_rotation: " << objectName << " " << value << std::endl;
logger() << "[script] set_object_rotation: " << objectName << " " << value << std::endl;
return;
}
}
@@ -243,7 +243,7 @@ namespace ZL {
for (auto& intObj : loc->interactiveObjects) {
if (intObj.loadedObject.name == objectName) {
intObj.state.alpha = value;
std::cout << "[script] set_object_alpha: " <<objectName << " " << value << std::endl;
logger() << "[script] set_object_alpha: " <<objectName << " " << value << std::endl;
return;
}
}
@@ -336,13 +336,13 @@ namespace ZL {
api.set_function("set_night",
[loc]() {
loc->requestNightDayTransition(true, false);
std::cout << "Set night called" << std::endl;
logger() << "Set night called" << std::endl;
});
api.set_function("set_dawn",
[loc]() {
loc->requestNightDayTransition(true, true);
std::cout << "Set dawn called" << std::endl;
logger() << "Set dawn called" << std::endl;
});
@@ -857,7 +857,7 @@ namespace ZL {
std::cerr << "[SCRIPT] on_npc_interact error: " << err.what() << "\n";
}
else {
std::cout << "[SCRIPT] on_npc_interact called with index " << npcIndex << std::endl;
logger() << "[SCRIPT] on_npc_interact called with index " << npcIndex << std::endl;
}
}
else {
@@ -883,7 +883,7 @@ namespace ZL {
}
sol::state& lua = impl->lua;
std::cout << "[SCRIPT] Looking for activate function: " << functionName << std::endl;
logger() << "[SCRIPT] Looking for activate function: " << functionName << std::endl;
sol::function activateFunc = lua[functionName];
@@ -891,7 +891,7 @@ namespace ZL {
throw std::runtime_error("[SCRIPT] Lua function not found: " + functionName);
}
std::cout << "[SCRIPT] Found function! Calling: " << functionName << std::endl;
logger() << "[SCRIPT] Found function! Calling: " << functionName << std::endl;
auto result = activateFunc();
if (!result.valid()) {
@@ -899,7 +899,7 @@ namespace ZL {
throw std::runtime_error("[SCRIPT] Error executing " + functionName + ": " + std::string(err.what()));
}
std::cout << "[SCRIPT] Function executed successfully!" << std::endl;
logger() << "[SCRIPT] Function executed successfully!" << std::endl;
}
void ScriptEngine::callItemPickupCallback(const std::string& objectName) {
@@ -914,18 +914,18 @@ namespace ZL {
sol::function activateFunc = lua["on_item_pickup"];
if (activateFunc.valid()) {
std::cout << "[SCRIPT] Callback found! Calling with argument: " << objectName << std::endl;
logger() << "[SCRIPT] Callback found! Calling with argument: " << objectName << std::endl;
auto result = activateFunc(objectName);
if (!result.valid()) {
sol::error err = result;
std::cerr << "[SCRIPT] on_item_pickup callback error: " << err.what() << "\n";
}
else {
std::cout << "[SCRIPT] Callback executed successfully!" << std::endl;
logger() << "[SCRIPT] Callback executed successfully!" << std::endl;
}
}
else {
std::cout << "[SCRIPT] Fallback: on_item_pickup not found" << std::endl;
logger() << "[SCRIPT] Fallback: on_item_pickup not found" << std::endl;
}
}