[solved]Lua question

Discussion about everything. New games, 3d math, development tips...

[solved]Lua question

Postby REDDemon » Mon Dec 19, 2011 12:31 pm

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

I want to use the
cpp 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.
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 832
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: Lua question

Postby Radikalizm » Mon Dec 19, 2011 4:44 pm

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?
Radikalizm
 
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Lua question

Postby REDDemon » Mon Dec 19, 2011 5:29 pm

exactly the expected answer! thanks! so I should use something like:
cpp 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.
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 832
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)


Return to Off-topic

Who is online

Users browsing this forum: No registered users and 1 guest