From 00807670b92025b909e7bfff1fffb995feb03906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=E2=80=98Touky=E2=80=99=20Huet?= Date: Thu, 12 Mar 2015 02:09:49 +0000 Subject: [PATCH] Easymesh test tuto works with lua, but EzMesh seems broken. --- doc/tutorial/05_easymesh.cpp | 27 +++--- doc/tutorial/05_easymesh.lua | 81 +++++++++++++++++ doc/tutorial/05_easymesh.vcxproj | 147 ++++++++++++++++--------------- src/easymesh/easymeshbuild.h | 2 +- src/easymesh/easymeshlua.cpp | 126 +++++++++++++------------- src/easymesh/easymeshlua.h | 11 ++- src/lolua/baselua.cpp | 22 +++-- 7 files changed, 263 insertions(+), 153 deletions(-) create mode 100644 doc/tutorial/05_easymesh.lua diff --git a/doc/tutorial/05_easymesh.cpp b/doc/tutorial/05_easymesh.cpp index c1b4987a..5ee5fca5 100644 --- a/doc/tutorial/05_easymesh.cpp +++ b/doc/tutorial/05_easymesh.cpp @@ -27,26 +27,33 @@ class EasyMeshTutorial : public WorldEntity public: EasyMeshTutorial() { - m_gears.Push(EasyMesh(), mat4(1.0f), 0.0f); - m_gears.Push(EasyMesh(), mat4(1.0f), 0.0f); - m_gears.Push(EasyMesh(), mat4(1.0f), 180.0f / 18); - m_gears.Push(EasyMesh(), mat4(1.0f), 180.0f / 18); - m_gears.Push(EasyMesh(), mat4(1.0f), 180.0f / 18); - + EasyMeshLuaLoader EzMhLoader; + EzMhLoader.ExecLua("05_easymesh.lua"); + + EasyMeshLuaObject* gears0 = EzMhLoader.GetPtr("g0"); + EasyMeshLuaObject* gears1 = EzMhLoader.GetPtr("g1"); + EasyMeshLuaObject* gears2 = EzMhLoader.GetPtr("g2"); + EasyMeshLuaObject* gears3 = EzMhLoader.GetPtr("g3"); + EasyMeshLuaObject* gears4 = EzMhLoader.GetPtr("g4"); + + m_gears.Push(gears0->GetMesh(), mat4(1.0f), 0.0f); + m_gears.Push(gears1->GetMesh(), mat4(1.0f), 0.0f); + m_gears.Push(gears2->GetMesh(), mat4(1.0f), 180.0f / 18); + m_gears.Push(gears3->GetMesh(), mat4(1.0f), 180.0f / 18); + m_gears.Push(gears4->GetMesh(), mat4(1.0f), 180.0f / 18); + + /* m_gears[0].m1.Compile("[sc#00f ab 8 1 8 ty -.25]" "[sc#f9f scb#f9f acg 12 10 5 5 20 20 5 5 0.1 0 s .1 .1 .1 ty -.1 csgu]" "[sc#fff scb#000 acg 12 10 10 10 20 20 5 5 0.1 0 s .05 .05 .05 tx -1.5 ty .3 csgu]" "[sc#00f ab 5 3 9 tx 2.5 csgs]" "[[ sc#fff ab 3 1.4 2 tx -2 tz -2 " "[sc#fff ab 2.1 .7 1.1 ty .5 tx -1.4 tz -1.4 csgs] mz] csgu]"); - //m_gears[0].m1.Compile("[sc#f9f scb#f9f acg 12 10 5 5 20 20 5 5 0.1 0 s .1 .1 .1 [sc#00f ab 3 1 2 ty .25 tx 1 csgs]]"); m_gears[1].m1.Compile("sc#ff9 scb#ff9 acg 54 10 95 95 90 90 -5 -5 0.1 0 s .1 .1 .1"); - //m_gears[2].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1 [sc#00f scb#00f ab 2 2 2 tx 1.5]"); - //m_gears[3].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1 [sc#00f scb#00f ab 2 2 2 tx 1.5]"); - //m_gears[4].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1 [sc#00f scb#00f ab 2 2 2 tx 1.5]"); m_gears[2].m1.Compile("[sc#0f0 ab 2 2 2 t .8 .8 .8 rx 20 ry 20 [sc#00f ab 2 2 2 tx 0 csgu]]"); m_gears[3].m1.Compile("[sc#0f0 ab 2 2 2 t .8 .8 .8 rx 20 ry 20 [sc#00f ab 2 2 2 tx 0 csgs]]"); m_gears[4].m1.Compile("[sc#0f0 ab 2 2 2 t .8 .8 .8 rx 20 ry 20 [sc#00f ab 2 2 2 tx 0 csga]]"); + */ m_angle = 0; diff --git a/doc/tutorial/05_easymesh.lua b/doc/tutorial/05_easymesh.lua new file mode 100644 index 00000000..0de79fd5 --- /dev/null +++ b/doc/tutorial/05_easymesh.lua @@ -0,0 +1,81 @@ +do_g0 = false +do_g1 = false +do_g2 = true +do_g3 = true +do_g4 = true + +-- Gear 0: New style +g0 = EasyMesh.New(); +if do_g0 then + g0:BraceOpen() + g0:SetColor("#00f") + g0:AddBox(8, 1, 8) + g0:TranslateY(-.25) + g0:BraceClose() + g0:BraceOpen() + g0:SetColor("#f9f") + g0:SetColorB("#f9f") + g0:AddCog(12, 10, 5, 5, 20, 20, 5, 5, 0.1, 0) + g0:Scale(.1) + g0:TranslateY(-.1) + -- csgu + g0:BraceClose() + g0:BraceOpen() + g0:SetColor("#fff") + g0:SetColorB("#000") + g0:AddCog(12, 10, 10, 10, 20, 20, 5, 5, 0.1, 0) + g0:Scale(.05) + g0:TranslateX(-1.5) + g0:TranslateY(.3) + -- csgu + g0:BraceClose() + g0:BraceOpen() + g0:SetColor("#00f") + g0:AddBox(5, 3, 9) + g0:TranslateX(2.5) + -- csgs + g0:BraceClose() + g0:BraceOpen() + g0:BraceOpen() + g0:SetColor("#fff") + g0:AddBox(3, 1.4, 2) + g0:TranslateX(-2) + g0:TranslateZ(-2) + g0:BraceOpen() + g0:SetColor("#fff") + g0:AddBox(2.1, .7, 1.1) + g0:TranslateY(.5) + g0:TranslateX(-1.4) + g0:TranslateZ(-1.4) + -- csgs + g0:BraceClose() + g0:MirrorZ() + g0:BraceClose() + -- csgu + g0:BraceClose() +end + +-- Gear 1: Old style +g1 = EasyMesh.New(); +if do_g1 then + g1:sc("#ff9"); g1:scb("#ff9"); g1:acog(54, 10, 95, 95, 90, 90, -5, -5, 0.1, 0); g1:s(.1); +end + +-- Other Gears +g2 = EasyMesh.New(); +if do_g2 then + g2:bop(); g2:sc("#0f0"); g2:ab(2, 2, 2); g2:t(.8); g2:rx(20); g2:ry(20); g2:bop(); g2:sc("#00f"); g2:ab(2); g2:tx(0); --csgu + g2:bcl(); g2:bcl(); +end + +g3 = EasyMesh.New(); +if do_g3 then + g3:bop(); g3:sc("#0f0"); g3:ab(2); g3:t(.8); g3:rx(20); g3:ry(20); g3:bop(); g3:sc("#00f"); g3:ab(2); g3:tx(0); --csgs + g3:bcl(); g3:bcl(); +end + +g4 = EasyMesh.New(); +if do_g4 then + g3:bop(); g3:sc("#0f0"); g3:ab(2); g3:t(.8); g3:rx(20); g3:ry(20); g3:bop(); g3:sc("#00f"); g3:ab(2); g3:tx(0); --csga + g3:bcl(); g3:bcl(); +end diff --git a/doc/tutorial/05_easymesh.vcxproj b/doc/tutorial/05_easymesh.vcxproj index 09fbcacb..5e9576bd 100644 --- a/doc/tutorial/05_easymesh.vcxproj +++ b/doc/tutorial/05_easymesh.vcxproj @@ -1,71 +1,76 @@ - - - - - Debug - ORBIS - - - Debug - Win32 - - - Debug - x64 - - - Debug - Xbox 360 - - - Release - ORBIS - - - Release - Win32 - - - Release - x64 - - - Release - Xbox 360 - - - - - - - - {9e62f2fe-3408-4eae-8238-fd84238ceeda} - - - {83d3b207-c601-4025-8f41-01dedc354661} - - - {d84021ca-b233-4e0f-8a52-071b83bbccc4} - - - - {1c5b8702-290c-42da-aa9e-671348f5b747} - Application - Win32Proj - - - - - - - - - - - - - - - - - + + + + + Debug + ORBIS + + + Debug + Win32 + + + Debug + x64 + + + Debug + Xbox 360 + + + Release + ORBIS + + + Release + Win32 + + + Release + x64 + + + Release + Xbox 360 + + + + + + + + {9e62f2fe-3408-4eae-8238-fd84238ceeda} + + + {83d3b207-c601-4025-8f41-01dedc354661} + + + {d84021ca-b233-4e0f-8a52-071b83bbccc4} + + + + + true + + + + {1c5b8702-290c-42da-aa9e-671348f5b747} + Application + Win32Proj + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/easymesh/easymeshbuild.h b/src/easymesh/easymeshbuild.h index 5dc97ad8..4d3138d5 100644 --- a/src/easymesh/easymeshbuild.h +++ b/src/easymesh/easymeshbuild.h @@ -493,7 +493,7 @@ public: array m_texcoord_custom_build2[MeshType::MAX]; uint32_t m_texcoord_build_type[MeshType::MAX]; uint32_t m_texcoord_build_type2[MeshType::MAX]; - uint32_t m_build_flags; + uint32_t m_build_flags = MeshBuildOperation::PreventVertCleanup; }; //VDictType -- A safe enum for VertexDictionnary operations. ------------------ diff --git a/src/easymesh/easymeshlua.cpp b/src/easymesh/easymeshlua.cpp index 19b7b1cc..0a741cce 100644 --- a/src/easymesh/easymeshlua.cpp +++ b/src/easymesh/easymeshlua.cpp @@ -57,91 +57,93 @@ EasyMeshLuaObject* EasyMeshLuaObject::New(LuaState* l, int arg_nb) //----------------------------------------------------------------------------- const LuaObjectLib* EasyMeshLuaObject::GetLib() { + typedef EasyMeshLuaObject EMLO; static const LuaObjectLib lib = LuaObjectLib( "EasyMesh", //Statics - { /*{ nullptr, nullptr }*/ }, + { { nullptr, nullptr } }, //Methods { //----------------------------------------------------------------- - { "AddCylinder", &AppendCylinder }, { "ac", &AppendCylinder }, - { "AddSphere", &AppendSphere }, { "asph", &AppendSphere }, - { "AddCapsule", &AppendCapsule }, { "acap", &AppendCapsule }, - { "AddTorus", &AppendTorus }, { "ato", &AppendTorus }, - { "AddBox", &AppendBox }, { "ab", &AppendBox }, - { "AddStar", &AppendStar }, { "as", &AppendStar }, - { "AddExpandedStar", &AppendExpandedStar }, { "aes", &AppendExpandedStar }, - { "AddDisc", &AppendDisc }, { "ad", &AppendDisc }, - { "AddTriangle", &AppendSimpleTriangle }, { "at", &AppendSimpleTriangle }, - { "AddQuad", &AppendSimpleQuad }, { "aq", &AppendSimpleQuad }, - { "AddCog", &AppendCog }, { "acog", &AppendCog }, + { "AddCylinder", &EMLO::AppendCylinder }, { "ac", &EMLO::AppendCylinder }, + { "AddSphere", &EMLO::AppendSphere }, { "asph", &EMLO::AppendSphere }, + { "AddCapsule", &EMLO::AppendCapsule }, { "acap", &EMLO::AppendCapsule }, + { "AddTorus", &EMLO::AppendTorus }, { "ato", &EMLO::AppendTorus }, + { "AddBox", &EMLO::AppendBox }, { "ab", &EMLO::AppendBox }, + { "AddStar", &EMLO::AppendStar }, { "as", &EMLO::AppendStar }, + { "AddExpandedStar", &EMLO::AppendExpandedStar }, { "aes", &EMLO::AppendExpandedStar }, + { "AddDisc", &EMLO::AppendDisc }, { "ad", &EMLO::AppendDisc }, + { "AddTriangle", &EMLO::AppendSimpleTriangle }, { "at", &EMLO::AppendSimpleTriangle }, + { "AddQuad", &EMLO::AppendSimpleQuad }, { "aq", &EMLO::AppendSimpleQuad }, + { "AddCog", &EMLO::AppendCog }, { "acog", &EMLO::AppendCog }, //----------------------------------------------------------------- - { "setcolor", &SetCurColor }, { "sc", &SetCurColor }, - { "setcolora", &SetCurColorA }, { "sca", &SetCurColorA }, - { "setcolorb", &SetCurColorB }, { "scb", &SetCurColorB }, - { "setcolorv", &SetVertColor }, { "scv", &SetVertColor }, + { "SetColor", &EMLO::SetCurColor }, { "sc", &EMLO::SetCurColor }, + { "SetColorA", &EMLO::SetCurColorA }, { "sca", &EMLO::SetCurColorA }, + { "SetColorB", &EMLO::SetCurColorB }, { "scb", &EMLO::SetCurColorB }, + { "SetColorV", &EMLO::SetVertColor }, { "scv", &EMLO::SetVertColor }, //----------------------------------------------------------------- - { "TranslateX", &TranslateX }, { "tx", &TranslateX }, - { "TranslateY", &TranslateY }, { "ty", &TranslateY }, - { "TranslateZ", &TranslateZ }, { "tz", &TranslateZ }, + { "TranslateX", &EMLO::TranslateX }, { "tx", &EMLO::TranslateX }, + { "TranslateY", &EMLO::TranslateY }, { "ty", &EMLO::TranslateY }, + { "TranslateZ", &EMLO::TranslateZ }, { "tz", &EMLO::TranslateZ }, { "Translate", &Translate }, { "t", &Translate }, //----------------------------------------------------------------- - { "RotateX", &RotateX }, { "rx", &RotateX }, - { "RotateY", &RotateY }, { "ry", &RotateY }, - { "RotateZ", &RotateZ }, { "rz", &RotateZ }, + { "RotateX", &EMLO::RotateX }, { "rx", &EMLO::RotateX }, + { "RotateY", &EMLO::RotateY }, { "ry", &EMLO::RotateY }, + { "RotateZ", &EMLO::RotateZ }, { "rz", &EMLO::RotateZ }, { "Rotate", &Rotate }, { "r", &Rotate }, //----------------------------------------------------------------- - { "ScaleX", &ScaleX }, { "sx", &ScaleX }, - { "ScaleY", &ScaleY }, { "sy", &ScaleY }, - { "ScaleZ", &ScaleZ }, { "sz", &ScaleZ }, - { "Scale", &Scale }, { "s", &Scale }, + { "ScaleX", &EMLO::ScaleX }, { "sx", &EMLO::ScaleX }, + { "ScaleY", &EMLO::ScaleY }, { "sy", &EMLO::ScaleY }, + { "ScaleZ", &EMLO::ScaleZ }, { "sz", &EMLO::ScaleZ }, + { "Scale", &EMLO::Scale }, { "s", &EMLO::Scale }, //----------------------------------------------------------------- - { "RadialJitter", &RadialJitter }, { "rj", &RadialJitter }, + { "RadialJitter", &EMLO::RadialJitter }, { "rj", &EMLO::RadialJitter }, //----------------------------------------------------------------- - { "TaperX", &TaperX }, { "tax", &TaperX }, - { "TaperY", &TaperY }, { "tay", &TaperY }, - { "TaperZ", &TaperZ }, { "taz", &TaperZ }, + { "TaperX", &EMLO::TaperX }, { "tax", &EMLO::TaperX }, + { "TaperY", &EMLO::TaperY }, { "tay", &EMLO::TaperY }, + { "TaperZ", &EMLO::TaperZ }, { "taz", &EMLO::TaperZ }, //----------------------------------------------------------------- - { "TwistX", &TwistX }, { "twx", &TwistX }, - { "TwistY", &TwistY }, { "twy", &TwistY }, - { "TwistZ", &TwistZ }, { "twz", &TwistZ }, + { "TwistX", &EMLO::TwistX }, { "twx", &EMLO::TwistX }, + { "TwistY", &EMLO::TwistY }, { "twy", &EMLO::TwistY }, + { "TwistZ", &EMLO::TwistZ }, { "twz", &EMLO::TwistZ }, //----------------------------------------------------------------- - { "ShearX", &ShearX }, { "shx", &ShearX }, - { "ShearY", &ShearY }, { "shy", &ShearY }, - { "ShearZ", &ShearZ }, { "shz", &ShearZ }, + { "ShearX", &EMLO::ShearX }, { "shx", &EMLO::ShearX }, + { "ShearY", &EMLO::ShearY }, { "shy", &EMLO::ShearY }, + { "ShearZ", &EMLO::ShearZ }, { "shz", &EMLO::ShearZ }, //----------------------------------------------------------------- - { "StretchX", &StretchX }, { "stx", &StretchX }, - { "StretchY", &StretchY }, { "sty", &StretchY }, - { "StretchZ", &StretchZ }, { "stz", &StretchZ }, + { "StretchX", &EMLO::StretchX }, { "stx", &EMLO::StretchX }, + { "StretchY", &EMLO::StretchY }, { "sty", &EMLO::StretchY }, + { "StretchZ", &EMLO::StretchZ }, { "stz", &EMLO::StretchZ }, //----------------------------------------------------------------- - { "BendXY", &BendXY }, { "bdxy", &BendXY }, - { "BendXZ", &BendXZ }, { "bdxz", &BendXZ }, - { "BendYX", &BendYX }, { "bdyx", &BendYX }, - { "BendYZ", &BendYZ }, { "bdyz", &BendYZ }, - { "BendZX", &BendZX }, { "bdzx", &BendZX }, - { "BendZY", &BendZY }, { "bdzy", &BendZY }, + { "BendXY", &EMLO::BendXY }, { "bdxy", &EMLO::BendXY }, + { "BendXZ", &EMLO::BendXZ }, { "bdxz", &EMLO::BendXZ }, + { "BendYX", &EMLO::BendYX }, { "bdyx", &EMLO::BendYX }, + { "BendYZ", &EMLO::BendYZ }, { "bdyz", &EMLO::BendYZ }, + { "BendZX", &EMLO::BendZX }, { "bdzx", &EMLO::BendZX }, + { "BendZY", &EMLO::BendZY }, { "bdzy", &EMLO::BendZY }, //----------------------------------------------------------------- - { "MirrorX", &MirrorX }, { "mx", &MirrorX }, - { "MirrorY", &MirrorY }, { "my", &MirrorY }, - { "MirrorZ", &MirrorZ }, { "mz", &MirrorZ }, + { "MirrorX", &EMLO::MirrorX }, { "mx", &EMLO::MirrorX }, + { "MirrorY", &EMLO::MirrorY }, { "my", &EMLO::MirrorY }, + { "MirrorZ", &EMLO::MirrorZ }, { "mz", &EMLO::MirrorZ }, //----------------------------------------------------------------- - { "Loop", &LoopStart }, { "lp", &LoopStart }, - { "LoopDo", &LoopEnd }, { "ld", &LoopEnd }, - { "BraceOpen", &OpenBrace }, { "bop", &OpenBrace }, - { "BraceClose", &CloseBrace }, { "bcl", &CloseBrace }, + { "Loop", &EMLO::LoopStart }, { "lp", &EMLO::LoopStart }, + { "LoopDo", &EMLO::LoopEnd }, { "ld", &EMLO::LoopEnd }, + { "BraceOpen", &EMLO::OpenBrace }, { "bop", &EMLO::OpenBrace }, + { "BraceClose", &EMLO::CloseBrace }, { "bcl", &EMLO::CloseBrace }, //----------------------------------------------------------------- - { "VerticeMerge", &VerticesMerge }, { "vm", &VerticesMerge }, - { "VerticeSeparate", &VerticesSeparate }, { "vs", &VerticesSeparate }, + { "VerticeMerge", &EMLO::VerticesMerge }, { "vm", &EMLO::VerticesMerge }, + { "VerticeSeparate", &EMLO::VerticesSeparate }, { "vs", &EMLO::VerticesSeparate }, + { "VerticesCleanup", &EMLO::VerticesCleanup }, { "vc", &EMLO::VerticesCleanup }, //----------------------------------------------------------------- - { "Duplicate", &Duplicate }, { "dup", &Duplicate }, - { "Smooth", &Smooth }, { "smth", &Smooth }, - { "SplitTriangles", &SplitTriangles }, { "splt", &SplitTriangles }, - { "Chamfer", &Chamfer }, { "cf", &Chamfer }, + { "Duplicate", &EMLO::Duplicate }, { "dup", &EMLO::Duplicate }, + { "Smooth", &EMLO::Smooth }, { "smth", &EMLO::Smooth }, + { "SplitTriangles", &EMLO::SplitTriangles }, { "splt", &EMLO::SplitTriangles }, + { "Chamfer", &EMLO::Chamfer }, { "cf", &EMLO::Chamfer }, //----------------------------------------------------------------- - { "ToggleScaleWinding", &ToggleScaleWinding }, { "tsw", &ToggleScaleWinding }, - { "ToggleQuadWeighting", &ToggleQuadWeighting }, { "tqw", &ToggleQuadWeighting }, - { "TogglePostBuildNormal", &TogglePostBuildNormal }, { "tpbn", &TogglePostBuildNormal }, - { "ToggleVerticeNoCleanup", &ToggleVerticeNoCleanup }, { "tvnc", &ToggleVerticeNoCleanup }, + { "ToggleScaleWinding", &EMLO::ToggleScaleWinding }, { "tsw", &EMLO::ToggleScaleWinding }, + { "ToggleQuadWeighting", &EMLO::ToggleQuadWeighting }, { "tqw", &EMLO::ToggleQuadWeighting }, + { "TogglePostBuildNormal", &EMLO::TogglePostBuildNormal }, { "tpbn", &EMLO::TogglePostBuildNormal }, + { "ToggleVerticeNoCleanup", &EMLO::ToggleVerticeNoCleanup }, { "tvnc", &EMLO::ToggleVerticeNoCleanup }, //----------------------------------------------------------------- }, //Variables diff --git a/src/easymesh/easymeshlua.h b/src/easymesh/easymeshlua.h index 3a14af80..95ef8912 100644 --- a/src/easymesh/easymeshlua.h +++ b/src/easymesh/easymeshlua.h @@ -32,6 +32,7 @@ public: //------------------------------------------------------------------------- EasyMeshLuaObject(); virtual ~EasyMeshLuaObject(); + EasyMesh& GetMesh() { return m_instance; } //------------------------------------------------------------------------- static EasyMeshLuaObject* New(LuaState* l, int arg_nb); @@ -558,6 +559,14 @@ public: m->m_instance.VerticesSeparate(); return 0; } + static int VerticesCleanup(LuaState* l) + { + LuaStack s(l); + EzMeshPtr m; + s >> m; + m->m_instance.VerticesCleanup(); + return 0; + } //------------------------------------------------------------------------- static int Duplicate(LuaState* l) { @@ -602,7 +611,7 @@ public: EzMeshPtr m; s >> m; LuaVec4 c; - if (s.GetArgs() == 1 && !c.IsValid(l, 2)) + if (s.GetArgs() == 2 && !c.IsValid(l, 2)) { LuaString str; s >> str; diff --git a/src/lolua/baselua.cpp b/src/lolua/baselua.cpp index 3bda66b3..48d33564 100644 --- a/src/lolua/baselua.cpp +++ b/src/lolua/baselua.cpp @@ -25,21 +25,21 @@ class LuaBaseData { friend class Lolua::Loader; - static int LuaPanic(LuaState* L) + static int LuaPanic(LuaState* l) { - char const *message = lua_tostring(L, -1); + char const *message = lua_tostring(l, -1); Log::Error("%s\n", message); DebugAbort(); return 0; } - static int LuaDoFile(LuaState *L) + static int LuaDoFile(LuaState *l) { - if (lua_isnoneornil(L, 1)) + if (lua_isnoneornil(l, 1)) return LUA_ERRFILE; - LuaCharPtr var; var.Get(L, 1); - char const *filename = var;// lua_tostring(L, 1); + LuaCharPtr var; var.Get(l, 1); + char const *filename = var;// lua_tostring(l, 1); int status = LUA_ERRFILE; array pathlist = System::GetPathList(filename); @@ -53,15 +53,21 @@ class LuaBaseData f.Close(); Log::Debug("loading Lua file %s\n", pathlist[i].C()); - status = luaL_dostring(L, s.C()); + status = luaL_dostring(l, s.C()); break; } } if (status == LUA_ERRFILE) Log::Error("could not find Lua file %s\n", filename); + else if (status == 1) + { + LuaString error; error.Get(l, -1); + Log::Error("Lua error %s\n", error().C()); + lua_pop(l, 1); + } - lua_pop(L, 1); + lua_pop(l, 1); return status; }