Browse Source

Lua: Correct chunkname (#138)

* Correct chunkname

* Add source path for dostring
actboy168 5 years ago
parent
commit
e3b74a4d01
2 changed files with 5 additions and 2 deletions
  1. 1 1
      Source/Lua/Interpreter.cpp
  2. 4 1
      Source/Lua/LuaDocument.cpp

+ 1 - 1
Source/Lua/Interpreter.cpp

@@ -67,7 +67,7 @@ void Interpreter::LoadFile(const String& file)
     file_interface->Read(file_contents, size, handle);
     file_interface->Close(handle);
 
-    if (luaL_loadbuffer(L, file_contents, size, file.c_str()) != 0)
+    if (luaL_loadbuffer(L, file_contents, size, ("@" + file).c_str()) != 0)
         Report(L);
     else //if there were no errors loading, then the compiled function is on the top of the stack
     {

+ 4 - 1
Source/Lua/LuaDocument.cpp

@@ -49,8 +49,11 @@ void LuaDocument::LoadScript(Stream* stream, const String& source_name)
     else
     {
         String buffer;
+        buffer += "--";
+        buffer += this->GetSourceURL();
+        buffer += "\n";
         stream->Read(buffer,stream->Length()); //just do the whole thing
-        Interpreter::DoString(buffer, this->GetSourceURL());
+        Interpreter::DoString(buffer, buffer);
     }
 }