@@ -54,30 +54,29 @@ namespace wi::lua
54
54
return scriptpid_next.fetch_add (1 );
55
55
}
56
56
57
- uint32_t AttachScriptParameters (std::string& script, const std::string& filename, uint32_t PID, const std::string& customparameters_prepend, const std::string& customparameters_append)
58
- {
59
- static const std::string persistent_inject = R"(
60
- local runProcess = function(func)
61
- success, co = Internal_runProcess(script_file(), script_pid(), func)
62
- return success, co
63
- end
64
- if _ENV.PROCESSES_DATA[script_pid()] == nil then
65
- _ENV.PROCESSES_DATA[script_pid()] = { _INITIALIZED = -1 }
66
- end
67
- if _ENV.PROCESSES_DATA[script_pid()]._INITIALIZED < 1 then
68
- _ENV.PROCESSES_DATA[script_pid()]._INITIALIZED = _ENV.PROCESSES_DATA[script_pid()]._INITIALIZED + 1
69
- end
70
- )" ;
57
+ uint32_t AttachScriptParameters (std::string& script, const std::string& filename, uint32_t PID, const std::string& customparameters_prepend, const std::string& customparameters_append)
58
+ {
59
+ static const std::string persistent_inject =
60
+ " local runProcess = function(func) "
61
+ " success, co = Internal_runProcess(script_file(), script_pid(), func);"
62
+ " return success, co;"
63
+ " end;"
64
+ " if _ENV.PROCESSES_DATA[script_pid()] == nil then"
65
+ " _ENV.PROCESSES_DATA[script_pid()] = { _INITIALIZED = -1 };"
66
+ " end;"
67
+ " if _ENV.PROCESSES_DATA[script_pid()]._INITIALIZED < 1 then"
68
+ " _ENV.PROCESSES_DATA[script_pid()]._INITIALIZED = _ENV.PROCESSES_DATA[script_pid()]._INITIALIZED + 1;"
69
+ " end;" ;
71
70
72
71
// Make sure the file path doesn't contain backslash characters, replace them with forward slash.
73
72
// - backslash would be recognized by lua as escape character
74
73
// - the path string could be coming from unknown location (content, programmer, filepicker), so always do this
75
74
std::string filepath = filename;
76
75
std::replace (filepath.begin (), filepath.end (), ' \\ ' , ' /' );
77
76
78
- std::string dynamic_inject = " local function script_file() return \" " + filepath + " \" end\n " ;
79
- dynamic_inject += " local function script_pid() return \" " + std::to_string (PID) + " \" end\n " ;
80
- dynamic_inject += " local function script_dir() return \" " + wi::helper::GetDirectoryFromPath (filepath) + " \" end\n " ;
77
+ std::string dynamic_inject = " local function script_file() return \" " + filepath + " \" end; " ;
78
+ dynamic_inject += " local function script_pid() return \" " + std::to_string (PID) + " \" end; " ;
79
+ dynamic_inject += " local function script_dir() return \" " + wi::helper::GetDirectoryFromPath (filepath) + " \" end; " ;
81
80
dynamic_inject += persistent_inject;
82
81
script = dynamic_inject + customparameters_prepend + script + customparameters_append;
83
82
@@ -537,12 +536,11 @@ namespace wi::lua
537
536
{
538
537
ss += error;
539
538
}
540
- wi::backlog::post (ss);
539
+ wi::backlog::post (ss, wi::backlog::LogLevel::Error );
541
540
}
542
541
543
542
void SAddMetatable (lua_State* L, const std::string& name)
544
543
{
545
544
luaL_newmetatable (L, name.c_str ());
546
545
}
547
-
548
546
}
0 commit comments