Skip to content

Commit dc2c782

Browse files
committed
Always print LuaScript execution errors
1 parent c8c75f6 commit dc2c782

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/script-language/LuaScript.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,18 @@ Error LuaScript::_reload(bool keep_state) {
111111
placeholder_fallback_enabled = true;
112112
metadata.clear();
113113

114-
Variant result = LuaScriptLanguage::get_singleton()->get_lua_state()->do_string(source_code, get_path());
114+
Variant result = LuaScriptLanguage::get_singleton()->get_lua_state()->load_string(source_code, get_path());
115115
if (LuaError *error = Object::cast_to<LuaError>(result)) {
116+
if (!Engine::get_singleton()->is_editor_hint()) {
117+
ERR_PRINT(error->get_message());
118+
}
116119
return ERR_PARSE_ERROR;
117120
}
121+
122+
result = Object::cast_to<LuaFunction>(result)->invokev(Array());
123+
if (LuaError *error = Object::cast_to<LuaError>(result)) {
124+
ERR_PRINT(result);
125+
}
118126
else if (LuaTable *table = Object::cast_to<LuaTable>(result)) {
119127
placeholder_fallback_enabled = false;
120128
metadata.setup(table->get_table());

src/script-language/LuaScriptLanguage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ Dictionary LuaScriptLanguage::_validate(const String &script, const String &path
153153
Variant f = lua_state->load_string(script, path);
154154
if (LuaError *error = Object::cast_to<LuaError>(f)) {
155155
if (validate_errors) {
156-
auto line_re = RegEx::create_from_string(R":(\d+):");
157-
auto match = line_re->search(error->get_message());
156+
Ref<RegEx> line_re = RegEx::create_from_string(R":(\d+):");
157+
Ref<RegExMatch> match = line_re->search(error->get_message());
158158
Dictionary error_dict;
159159
error_dict["path"] = path;
160160
error_dict["line"] = match->get_string().to_int();

0 commit comments

Comments
 (0)