www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [Derelict-Lua] FileSystem Trouble: Strange Behavior.

Hello! I have been trying to embed lua into my application, and I 
have strange behavior that I could not understand. I'm sure that 
this is not normal.

First off, I have written a binding in order to interface my D 
code with Lua Code.
extern(C) nothrow int addSprite(lua_State *L){
         string path = to!string(lua_tostring(L,1));
         string name = to!string(lua_tostring(L,2));
     }catch(Exception e){
     return 0;

Now here is my lua script.



Now here is how I execute said lua scripts:
             int s = luaL_loadfile(L,cast(char*)script_list[name]);
                 s = lua_pcall(L,0,LUA_MULTRET,0);
                 write("Error : ");

Now the strange thing here is, I have around 5 lines of code that 
adds other sprites aside from "image.png" but for some strange 
reason, the other 4 does its job, but this line doesn't. There 
are no duplicates of this line of code, nor is it in the 
first/last position. It's smack in the middle.

Now, in a fit of desperation, I renamed the actual file and line 
into "imag.png"
And sure enough it worked! Lua could not find "image.png" but can 
find "imag.png"

And this repeats randomly everytime I add new lines into my lua 
script. Sometimes it affects other lines that worked before, but 
sometimes it doesn't.

Now my current problem is that I've been trying to do 
"loadfile()" in lua, and it doesn't find the .lua file I'm 
pointing to, even with absolute paths and Window-specific 

Any ideas?
Jan 31 2017