Hey, thanks zenaku ,I'll try it when get home.zenaku wrote:MarcoTMP, a new function 'irr.io.dofile(IReadFile)' is now implemented. You can now run scripts out of zip files.
IrrLua
Re: IrrLua-0.7 released
I have upgraded my little game to this version and didn't have any problems so far.
Is there any other way to launch an irrlua application unless using an msdos box? I would sugest an executable like start.exe that could be renamed and would read a start.ini file (or another name.ini if the file was renamed) to know whats the root lua script to run.
Im not such a big windows programmer so i can't do this myself.
Is there any other way to launch an irrlua application unless using an msdos box? I would sugest an executable like start.exe that could be renamed and would read a start.ini file (or another name.ini if the file was renamed) to know whats the root lua script to run.
Im not such a big windows programmer so i can't do this myself.
Here's a quick hack you can do to the 'LuaInterpreter' project.elander wrote:I have upgraded my little game to this version and didn't have any problems so far.
Is there any other way to launch an irrlua application unless using an msdos box? I would sugest an executable like start.exe that could be renamed and would read a start.ini file (or another name.ini if the file was renamed) to know whats the root lua script to run.
Im not such a big windows programmer so i can't do this myself.
In the LuaInterpreter project settings, under C++/Preprocessor settings, remove the '_CONSOLE' define. Under linker settings, open the system section and change the SubSystem from 'CONSOLE' to 'WINDOWS'.
At the top of LuaInterpreter.cpp, put the line:
Code: Select all
#include <windows.h>
Code: Select all
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
lua_State *l = lua_open();
lua_userinit(l);
int ret = lua_dofile(l, "startup.lua");
lua_close(l);
return ret;
}
Code: Select all
dofile("01.HelloWorld.lua")
In the example 02.Quake3Map.lua, at the top I do
Code: Select all
local answer = io.read("*line")
local driverTypes = {["a"] = irr.video.EDT_DIRECT3D9,
["b"] = irr.video.EDT_DIRECT3D8,
["c"] = irr.video.EDT_OPENGL,
["d"] = irr.video.EDT_SOFTWARE,
["e"] = irr.video.EDT_SOFTWARE2,
["f"] = irr.video.EDT_NULL }
local type = driverTypes[answer]
if type == nil then
return 0
-------------------------------------
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
Would it be possible to change the lua executable to detect when it is being called from dos prompt and when it is being called from explorer and select the apropriate startup method automaticaly? Like i said i don't understand much of windows programming so this is just a wild guess, but it would be very useful if this was possible. I know that some apps can do this and even start as app from a dos window and let the user close the dos window afterwards.
Anything is possible, but doing that is non-trivial.elander wrote:Would it be possible to change the lua executable to detect when it is being called from dos prompt and when it is being called from explorer and select the apropriate startup method automaticaly? Like i said i don't understand much of windows programming so this is just a wild guess, but it would be very useful if this was possible. I know that some apps can do this and even start as app from a dos window and let the user close the dos window afterwards.
In the code above, did you notice how the SubSystem crap is built into the compiler?
All windows programs need a WinMain(), even console programs that only implement main(). If your program is a console program and has no WinMain() (like lua.exe), windows gives you one (otherwise there would be no console window at all to display). That's where the subsystem crap comes in, and why it's a pain to change how that stuff works. To make it work how you describe you'd most likely have to make lua.exe implement WinMain() (like I posted above) and then implement your own console IO like stdin stdout, etc (not fun).
It would probably be a lot easier to just have two executables (lua.exe and WinLua.exe? ) and run which ever is appropriate.
-------------------------------------
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
I tried to download this stuff from the LuaZip site but unfortunalty the only thing they have is a .c file a zip.dll which i assumed it can only be used used to compile to whatever program is enbeding lua.zenaku wrote: For example, there is already a LuaZip library that should integrate well with IrrLua.
You could then do something like:
Code: Select all
require "zip" local zfile, err = zip.open('luazip.zip') -- print the filenames of the files inside the zip for file in zfile:files() do print(file.filename) end -- open myscript.lua and run it local f1, err = zfile:open('myscript.lua') dofile(f1)
It would be great if we could install a package by just copying the files zip.lua and zip.dll somewhere the simply use 'require "zip"' in our script.
This would gives an opurtunity to use lua jit:
http://luajit.luaforge.net/
My script startup would be:
luajit.exe main.lua
And in the main.lua source:
require "irrlua"
require "zip"
require "audiare"
require "newton"
require "dustyengine"
function main()
do stuff
end
Do you think this is possible?
All of that will be possible with Lua 5.1. The problem with lua 5.0 is there isn't a standard way of dealing with binary modules. You get loadlib() and that's about it. Lua 5.1 addresses that issue, so you can expect prebuilt binary modules for lua to start taking off with Lua 5.1. With Lua 5.0, you have to roll your own, which is what I did with IrrLua.elander wrote:I tried to download this stuff from the LuaZip site but unfortunalty the only thing they have is a .c file a zip.dll which i assumed it can only be used used to compile to whatever program is enbeding lua.zenaku wrote: For example, there is already a LuaZip library that should integrate well with IrrLua.
You could then do something like:
Code: Select all
require "zip" local zfile, err = zip.open('luazip.zip') -- print the filenames of the files inside the zip for file in zfile:files() do print(file.filename) end -- open myscript.lua and run it local f1, err = zfile:open('myscript.lua') dofile(f1)
It would be great if we could install a package by just copying the files zip.lua and zip.dll somewhere the simply use 'require "zip"' in our script.
This would gives an opurtunity to use lua jit:
http://luajit.luaforge.net/
My script startup would be:
luajit.exe main.lua
And in the main.lua source:
require "irrlua"
require "zip"
require "audiare"
require "newton"
require "dustyengine"
function main()
do stuff
end
Do you think this is possible?
In IrrLua/pkg/IrrLua_package.lua, you can see how the binary module stuff is done in IrrLua. IrrLua_package.lua is compiled to lua p-code and put in the \bin directory as 'IrrLua.lua'. This way, you can do 'require "IrrLua"' and lua 5.0 runs the the IrrLua.lua file. In that file is where the DLL is actually loaded with loadlib(). I'm planning on moving IrrLua to Lua 5.1 as soon as I can. I just got a new job, so it might take a while. Expect IrrLua development to slow down while I get aquainted with my new job
I don't have my machine set up to test anything, but I just looked at the LuaZip package. I think you can make it work without compiling anything. The Zip.DLL that comes with it is the Lua binding. It's just a matter of loading it. The require keyword won't do it for you, as it only understands Lua files, not DLLs. You'll have to do something similar to what IrrLua does to make the 'require' keyword work with the zip lib.
-------------------------------------
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
it seem like a bug.
Code: Select all
function irr.gui.createIGUIElement(type, environment, parent, id, rectangle, def)
local o = {}
for i,v in pairs(def) do o[i] = v end
-- the line blow is right?
o.__c_class = irr.scene.IrrLuaIGUIElement:new()
tolua.inherit(o, o.__c_class)
tolua.takeownership(o)
o.__index = function (t, k) return rawget(t,"__c_class")[k] end
setmetatable(o, o)
irr.__iguielementproxy[o.__c_class:GetProxy()] = o
return o
end
Re: it seem like a bug.
The code above is broken.mgphuang wrote:and this function can not be call ,a nil value.Code: Select all
function irr.gui.createIGUIElement(type, environment, parent, id, rectangle, def) local o = {} for i,v in pairs(def) do o[i] = v end -- the line blow is right? o.__c_class = irr.scene.IrrLuaIGUIElement:new() tolua.inherit(o, o.__c_class) tolua.takeownership(o) o.__index = function (t, k) return rawget(t,"__c_class")[k] end setmetatable(o, o) irr.__iguielementproxy[o.__c_class:GetProxy()] = o return o end
1. IrrLuaIGUIElement should be a part of "irr.gui", not "irr.scene".
2. Neither the function irr.scene.IrrLuaIGUIElement or irr.gui.IrrLuaIGUIElement exist. The binding is broken and not exporting it. Sorry
My job is finally starting to slow down so expect another release of IrrLua within a few weeks.
I've ported IrrLua to Lua 5.1 and also to LuaBinaries. I still need to port over to Irrlicht 1.0 and fix these bugs and then I'll release it.
-------------------------------------
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
-
- Posts: 56
- Joined: Mon Jan 09, 2006 2:02 am
imagination304 wrote:Hi all,
I have no experience of using lua.
Will it slow down frame per second of irrlicht?
Thanks in advance
There isn't really a straight answer to that question. It depends on what you are trying to do.
Generally speaking, it will slow down a few frames per second, but not by much.
On my computer:
CDemo.lua (no vsync) - Max FPS == 529
CDemo.exe (no vsync) - Max FPS == 573
If your code uses a lot of callbacks such as shaders, it will slow down much more than that. Things like callbacks should be done in C++ even though you can also do them in Lua.
An irrlicht program usually has a rendering loop at the bottom, e.g. beginScene(); drawAll(); endScene(). In IrrLua, that loop is also implemented in Lua code. If it were implemented in C++ and run from Lua it would perform much faster. I'll probably supply a generic renderLoop() function in IrrLua in a later release that resolves this issue.
-------------------------------------
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
-
- Posts: 56
- Joined: Mon Jan 09, 2006 2:02 am
Uhm, when you run the demo, it's one of the options If you use vsync, the framerate doesn't change so you can't benchmark.imagination304 wrote:Hi zenaku
Thank you for your reply.
One more question: what is the difference between vsync and no vsync?
Thanks in advanceCDemo.lua (no vsync) - Max FPS == 529
CDemo.exe (no vsync) - Max FPS == 573
-------------------------------------
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/