From 6e9f1fafcc51abaf0893db1dad9e477acafd2846 Mon Sep 17 00:00:00 2001 From: Gopmyc Date: Fri, 1 May 2026 18:03:41 +0200 Subject: [PATCH] fix(lua): replace spaces in default script identifier --- .../src/OvCore/Scripting/Lua/LuaScriptEngine.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Sources/OvCore/src/OvCore/Scripting/Lua/LuaScriptEngine.cpp b/Sources/OvCore/src/OvCore/Scripting/Lua/LuaScriptEngine.cpp index 5fabf8523..a1fcc85bd 100644 --- a/Sources/OvCore/src/OvCore/Scripting/Lua/LuaScriptEngine.cpp +++ b/Sources/OvCore/src/OvCore/Scripting/Lua/LuaScriptEngine.cpp @@ -17,6 +17,7 @@ #include #include #include +#include void BindLuaActor(sol::state& p_state); void BindLuaComponents(sol::state& p_state); @@ -173,19 +174,22 @@ std::unordered_set OvCore::Scripting::LuaScriptEngineBase::GetValid template<> std::string OvCore::Scripting::LuaScriptEngineBase::GetDefaultScriptContent(const std::string& p_name) { + std::string scriptTableName = p_name; + OvTools::Utils::String::ReplaceAll(scriptTableName, " ", "_"); + return - "---@class " + p_name + " : Behaviour\n" - "local " + p_name + " =\n" + "---@class " + scriptTableName + " : Behaviour\n" + "local " + scriptTableName + " =\n" "{\n" "}\n" "\n" - "function " + p_name + ":OnStart()\n" + "function " + scriptTableName + ":OnStart()\n" "end\n" "\n" - "function " + p_name + ":OnUpdate(deltaTime)\n" + "function " + scriptTableName + ":OnUpdate(deltaTime)\n" "end\n" "\n" - "return " + p_name; + "return " + scriptTableName; } template<>