[solved]Lua question

Discussion about everything. New games, 3d math, development tips...
Post Reply
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

[solved]Lua question

Post by REDDemon »

how is it possible to load bytecode and lua files from c++ using irrlicht interface?

I want to use the

Code: Select all

 
lua_load
 
function

this is usefull because it should read a lua program directly from a ram memory buffer, but I'm stuck on how to get the C string from the "helloworld.lua" file wich is putted into and compressed archive ("script.zip") wich is opened by irrlicht. So my problem is to get the C string from a file using irrlicht. I tried something but seems that some characters are changed during loading.
Last edited by REDDemon on Wed Dec 21, 2011 3:58 pm, edited 1 time in total.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Lua question

Post by Radikalizm »

I did it like this:

You use a regular IReadFile to read in the contents of your lua file (binary or text, doesnt matter) into a buffer
Then you can use luaL_loadbuffer and pass it the buffer you created with the IReadFile and it will handle everything for you

The lua documentation can be quite confusing sometimes

I assume this is what you were talking about?
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: Lua question

Post by REDDemon »

exactly the expected answer! thanks! so I should use something like:

Code: Select all

 
long size= file->getSize();
char * str = new char[size];
file->read(str,size);
luaL_loadbuffer(L,str,size,filename);
delete str;
 
I will try immediatly.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Post Reply