abi>>forums

abi>>forums (http://www.anythingbutipod.com/forum/index.php)
-   Download Zen X-Fi2 Games & Applications (http://www.anythingbutipod.com/forum/forumdisplay.php?f=223)
-   -   [TOOL] LUAC Script Compiler (http://www.anythingbutipod.com/forum/showthread.php?t=53412)

ThievingSix 03-14-2010 11:33 PM

[TOOL] LUAC Script Compiler
 
1 Attachment(s)
A LUA compiler written in LUA. This application will only work within the simulator, and it's only meant to.

LUAC gives you a list of the applications in your applications folder used by the simulator. Click on one and it will compile the MAIN.LUA script. It will create a backup named MAIN.BAK.LUA.

Updated to compile all LUA files in the selected application folder(Not sub-folders though, maybe later). Example: All lua files in C:\Creative\ZEN X-Fi2\Applications\MyGame\

http://img194.imageshack.us/img194/8161/95984862.png

Tetrajak 03-15-2010 01:56 AM

Awesome tool, I can see this coming in handy.

Habhome 03-15-2010 02:50 AM

Indeed. I wrote my own little script to do it after your instructions, but this one requires less work ^^

ThievingSix 03-16-2010 05:30 PM

Updated to compile all LUA files in the application folder(Not sub-folders though, maybe later).

Tetrajak 03-16-2010 05:56 PM

After compiling a file, is it still possible to have it written to by another Lua file? (io.output)

Habhome 03-16-2010 06:04 PM

Quote:

Originally Posted by ThievingSix (Post 451923)
Updated to compile all LUA files in the application folder(Not sub-folders though, maybe later).

All LUA files? I don't think that's very good. I want to keep my codes uncompiled until I bundle them for release. Why not try and make you able to choose what app to compile the LUA files for?
And I also wonder like Tetrajak, if it compiles the "stat.lua" where I save stuff, will I be able to read and write to it?

ThievingSix 03-16-2010 06:15 PM

Quote:

Originally Posted by Tetrajak (Post 451933)
After compiling a file, is it still possible to have it written to by another Lua file? (io.output)

No, that's why it doesn't include sub-folders. I suppose you can use io.write(string.dump(loadstring(MyStatsInfo))), But you'd have to rewrite the whole file.

Quote:

Originally Posted by Habhome (Post 451936)
All LUA files? I don't think that's very good. I want to keep my codes uncompiled until I bundle them for release. Why not try and make you able to choose what app to compile the LUA files for?

I think you misunderstood. It compiles all lua files in a selected application folder. So if you have: "MAIN.LUA", "MYSCRIPT.LUA" in one application folder it will compile both of those. It doesn't compile every application. I'll update the first post to make it more clear.

Habhome 03-16-2010 07:00 PM

Quote:

Originally Posted by ThievingSix (Post 451940)
I think you misunderstood. It compiles all lua files in a selected application folder. So if you have: "MAIN.LUA", "MYSCRIPT.LUA" in one application folder it will compile both of those. It doesn't compile every application. I'll update the first post to make it more clear.

Aha, OK. Then I misunderstood. It's doing exactly what I'd want then ^^ thanks for clearing that up.

delirius 08-22-2011 10:14 AM

Does compiling scripts help to save memory? I have problem, that i am running out of memory in my app hypogeum.

jbob182 08-22-2011 10:34 AM

It only helps with startup, because the code will compile on runtime anyway.

delirius 08-23-2011 03:27 AM

It did help. Starting Hypogeum on player with scripts compiled doesn't crash the app.

I have 1 suggestion how to make LUAC more user friendly:
don't compile scripts to script.lua.COMP because if you have 20+ script you have to manually remane them back every time you compile them :(

- you could back em up to folder
- remane the backup rather then compiled scripts.

jbob182 08-23-2011 12:11 PM

Quote:

It did help. Starting Hypogeum on player with scripts compiled doesn't crash the app.

I have 1 suggestion how to make LUAC more user friendly:
don't compile scripts to script.lua.COMP because if you have 20+ script you have to manually remane them back every time you compile them :(

- you could back em up to folder
- remane the backup rather then compiled scripts.
It looks like i stand corrected :) . You can compile your own code with this function:

Code:

function compile(file)  -- this function will compile a file
    old = string.dump(assert(loadfile(file)));
    CodeOutput = io.open(file,"wb");
    CodeOutput:write(old);
    io.close(CodeOutput);
    old = nil;
end


Habhome 08-23-2011 02:54 PM

Quote:

Originally Posted by delirius (Post 570243)
It did help. Starting Hypogeum on player with scripts compiled doesn't crash the app.

I have 1 suggestion how to make LUAC more user friendly:
don't compile scripts to script.lua.COMP because if you have 20+ script you have to manually remane them back every time you compile them :(

- you could back em up to folder
- remane the backup rather then compiled scripts.

I modified the code for this app so that it renames the backup rather than the compiled file (doesn't put it in a folder still, seems as if there are no directory-creating IO functions in LUA...)
But, there is one flaw with doing it this way. If you compile the app twice, then it backs up your already compiled file, overwriting the uncompiled backup. That is why he did it the way he did I assume.

I will look into it a bit more to see if I can come up with a viable solution to prevent this from happening, I've got an idea...

jbob182 08-23-2011 03:41 PM

Quote:

I modified the code for this app so that it renames the backup rather than the compiled file (doesn't put it in a folder still, seems as if there are no directory-creating IO functions in LUA...)
http://keplerproject.github.com/luafilesystem/

It is a c module that you can use once compiled using the require function "require lfs"

then you can handle directories ( here is an example),
Code:

for file in lfs.dir[[C:\Program Files]] do
    if lfs.attributes(file,"mode") == "file" then print("found file, "..file)
    elseif lfs.attributes(file,"mode")== "directory" then print("found dir, "..file," containing:")
        for l in lfs.dir("C:\\Program Files\\"..file) do
            print("",l)
        end
    end
end

Keep in mind, dynamic libraries will only work on the adk

Habhome 08-23-2011 04:18 PM

Quote:

Originally Posted by jbob182 (Post 570328)
http://keplerproject.github.com/luafilesystem/

It is a c module that you can use once compiled using the require function "require lfs"

then you can handle directories ( here is an example),
Code:

for file in lfs.dir[[C:\Program Files]] do
    if lfs.attributes(file,"mode") == "file" then print("found file, "..file)
    elseif lfs.attributes(file,"mode")== "directory" then print("found dir, "..file," containing:")
        for l in lfs.dir("C:\\Program Files\\"..file) do
            print("",l)
        end
    end
end

Keep in mind, dynamic libraries will only work on the adk

Can't get it to work with just having the files there, do I need to compile or build it myself using the source? Can't find some simple instructions how to make it work.

On another note, fixed the over-writing bug so now if I could just make these folders work then I can upload it...

jbob182 08-23-2011 04:20 PM

1 Attachment(s)
Quote:

Can't get it to work with just having the files there, do I need to compile or build it myself using the source? Can't find some simple instructions how to make it work.
You must compile it to a dll , if you want i could probably send a compiled version, ( I have been using c modules in my code for a while ).

The dll will be in the attachments of this post

extract the dll to the root folder of the lua code and use ' require "lfs" ' to load it

------------------------------------------------------------------------------------------------------------------------------------------
This dll was built for a specific setup using some other dll's so it will crash, i will resetup the dll and the package and uploaded it again soon

--------------------------------------------------------------------
Its all working now, i re uploaded the zip

Habhome 08-23-2011 04:27 PM

Ah, thanks! I haven't used modules for LUA before, and I wasn't sure exactly what I'd need, and I wasn't sure how to compile it myself just right off the bat. I'm spoiled with Visual Studio and Eclipse... xD

jbob182 08-23-2011 04:35 PM

Make sure you re download the zip, i changed the setup so it wont crash,

Sample code:

Code:

require "lfs"
for file in lfs.dir[[C:\Program Files]] do
    if lfs.attributes(file,"mode") == "file" then print("found file, "..file)
    elseif lfs.attributes(file,"mode")== "directory" then print("found dir, "..file," containing:")
        for l in lfs.dir("C:\\Program Files\\"..file) do
            print("",l)
        end
    end
end


Habhome 08-23-2011 04:43 PM

I made it work by downloading and including the missing .dll, but thanks for the fix. I found that reference already as well online. Now my only issue is that it creates the folder, but I can't write to it, it says it doesn't exist, can't figure out why... Guess I need to head to bed soon, it's getting late. Thanks for the help! I'll hopefully have it working by tomorrow.

jbob182 08-23-2011 04:57 PM

Quote:

I made it work by downloading and including the missing .dll, but thanks for the fix. I found that reference already as well online. Now my only issue is that it creates the folder, but I can't write to it, it says it doesn't exist, can't figure out why... Guess I need to head to bed soon, it's getting late. Thanks for the help! I'll hopefully have it working by tomorrow.
I can, here is the code i use:

Code:

require "lfs"
lfs.mkdir (lfs.currentdir () .. "/HelloWorldDir")
myfile = io.open("/HelloWorldDir/TextFile.txt","w+")
myfile:write("Hello World!")
io.close(myfile)

After testing around, you would only get that error if the dir didnt exist, so you must be missing this part :lfs.currentdir () ..


All times are GMT -5. The time now is 10:12 PM.