Working on Android version
This commit is contained in:
1 parent
0975f3b9cd
commit
e773b51985
19 files changed
+418
-264
No files matched your search
+35
-3
@@ -861,7 +861,39 @@ namespace FRG {
|
||||
}
|
||||
});
|
||||
|
||||
lua.script_file(scriptPath);
|
||||
//lua.script_file(scriptPath);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
// Читаем файл в строку через SDL_RWops
|
||||
std::string scriptContent = readTextFile(scriptPath);
|
||||
if (scriptContent.empty()) {
|
||||
std::cerr << "[script] Failed to read script file or file is empty: " << scriptPath << "\n";
|
||||
}
|
||||
else {
|
||||
|
||||
// Загружаем (компилируем) строку скрипта. Вторым аргументом передаем имя для логов
|
||||
auto loadResult = lua.load(scriptContent, scriptPath);
|
||||
if (!loadResult.valid()) {
|
||||
sol::error err = loadResult;
|
||||
std::cerr << "[script] Lua compile error: " << err.what() << "\n";
|
||||
}
|
||||
else {
|
||||
// Если компиляция успешна — вызываем функцию для выполнения кода скрипта
|
||||
auto runResult = loadResult();
|
||||
if (!runResult.valid()) {
|
||||
sol::error err = runResult;
|
||||
std::cerr << "[script] Lua runtime error: " << err.what() << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
// На остальных платформах оставляем стандартную загрузку из файла
|
||||
auto result = lua.script_file(scriptPath, sol::script_pass_on_error);
|
||||
if (!result.valid()) {
|
||||
sol::error err = result;
|
||||
std::cerr << "[script] Lua load error: " << err.what() << "\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScriptEngine::callNpcInteractCallback(int npcIndex) {
|
||||
@@ -885,14 +917,14 @@ namespace FRG {
|
||||
std::cerr << "[SCRIPT] Lua function 'on_npc_interact' not found!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void ScriptEngine::runScript(const std::string& path) {
|
||||
auto result = impl->lua.safe_script_file(path, sol::script_pass_on_error);
|
||||
if (!result.valid()) {
|
||||
sol::error err = result;
|
||||
std::cerr << "[script] Error in " << path << ": " << err.what() << "\n";
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
void ScriptEngine::callActivateFunction(const std::string& functionName) {
|
||||
if (!impl) {
|
||||
|
||||
Reference in new issue
Block a user