android
  #1  
Old 03-14-2010, 10:33 PM
ThievingSix ThievingSix is offline
Member
 
Join Date: Aug 2008
Posts: 218
Default [TOOL] LUAC Script Compiler

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\

Attached Files
File Type: zip LUAC.zip (6.2 KB, 295 views)
__________________
Only ONE more functions in the Wiki need addressing!
Zen X-Fi2 LUA Wiki
Want to protect your applications? Click Here!
Tower Defense Thread
Zen Lock - Protect Your Zen!

Last edited by ThievingSix; 03-16-2010 at 05:16 PM.
Reply With Quote

Advertisement [Remove Advertisement]

  #2  
Old 03-15-2010, 12:56 AM
Tetrajak Tetrajak is offline
Member
 
Join Date: Feb 2010
Location: Oceania
Posts: 124
Default

Awesome tool, I can see this coming in handy.
Reply With Quote

  #3  
Old 03-15-2010, 01:50 AM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

Indeed. I wrote my own little script to do it after your instructions, but this one requires less work ^^
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #4  
Old 03-16-2010, 04:30 PM
ThievingSix ThievingSix is offline
Member
 
Join Date: Aug 2008
Posts: 218
Default

Updated to compile all LUA files in the application folder(Not sub-folders though, maybe later).
__________________
Only ONE more functions in the Wiki need addressing!
Zen X-Fi2 LUA Wiki
Want to protect your applications? Click Here!
Tower Defense Thread
Zen Lock - Protect Your Zen!
Reply With Quote

  #5  
Old 03-16-2010, 04:56 PM
Tetrajak Tetrajak is offline
Member
 
Join Date: Feb 2010
Location: Oceania
Posts: 124
Default

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

  #6  
Old 03-16-2010, 05:04 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

Quote:
Originally Posted by ThievingSix View Post
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?
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #7  
Old 03-16-2010, 05:15 PM
ThievingSix ThievingSix is offline
Member
 
Join Date: Aug 2008
Posts: 218
Default

Quote:
Originally Posted by Tetrajak View Post
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 View Post
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.
__________________
Only ONE more functions in the Wiki need addressing!
Zen X-Fi2 LUA Wiki
Want to protect your applications? Click Here!
Tower Defense Thread
Zen Lock - Protect Your Zen!
Reply With Quote

  #8  
Old 03-16-2010, 06:00 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

Quote:
Originally Posted by ThievingSix View Post
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.
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #9  
Old 08-22-2011, 09:14 AM
delirius delirius is offline
Member
 
Join Date: Feb 2010
Posts: 131
Default

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

  #10  
Old 08-22-2011, 09:34 AM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

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

  #11  
Old 08-23-2011, 02:27 AM
delirius delirius is offline
Member
 
Join Date: Feb 2010
Posts: 131
Default

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.
Reply With Quote

  #12  
Old 08-23-2011, 11:11 AM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

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
Reply With Quote

  #13  
Old 08-23-2011, 01:54 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

Quote:
Originally Posted by delirius View Post
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...
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #14  
Old 08-23-2011, 02:41 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

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
Reply With Quote

  #15  
Old 08-23-2011, 03:18 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

Quote:
Originally Posted by jbob182 View Post
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...
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #16  
Old 08-23-2011, 03:20 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

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
Attached Files
File Type: zip Lua File System.zip (82.5 KB, 10 views)

Last edited by jbob182; 08-23-2011 at 03:35 PM.
Reply With Quote

  #17  
Old 08-23-2011, 03:27 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

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
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #18  
Old 08-23-2011, 03:35 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

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

Last edited by jbob182; 08-23-2011 at 03:47 PM.
Reply With Quote

  #19  
Old 08-23-2011, 03:43 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

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.
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #20  
Old 08-23-2011, 03:57 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

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 () ..

Last edited by jbob182; 08-23-2011 at 04:09 PM.
Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 04:19 AM.