PDA

View Full Version : Sharing code between projects


kraigyb
08-18-2004, 12:51 PM
I have created many applications which are coded identically with the exception of some graphics, button layout, etc. I like to keep each application up-to-date, so when I make changes in one application I copy the changes from each action and paste them into my other applications, and then republish them.

I recently played with the Application.LoadScript command which seems like it would work great. I can copy the updated scripts to the individual CD_Root\AutoPlay\Scripts folder and then republish each application. What I don't like about this is that when the application is published, the script files must be distributed in the AutoPlay\Scripts folder where everyone can read and enjoy. Is it possible for the scripts to be compiled right into the application?

I read in the online help about Application.LoadScript, dofile, and require commands. What are the differences between them? Do I need to have a separate .lua files for each Object/Action? Is there an easier way to share code between projects?

Is there an an external .lua script editor for APM5?

Thanks much!
Craig Booth

Brett
08-18-2004, 01:00 PM
You could even keep the scripts in the C:\Program Files\AutoPlay Media Studio 5.0 Professional\Gallery\Scripts folder and then they will appear available to all projects.

Application.LoadScript would be the way to go for external scripts. Once loaded, you can call functions from the script.

As far as security goes, you could always use the Crypto plugin to encrypt/decrypt the scripts before reading them in. Or, you could even store the scripts in a SQLite database and then include the databse in each project and load and extract the scripts form there. There are many ways to do that.

As far as editing the scripts go, you can just edit them in a "dummy" project's Global Functions and then use the Advanced menu's save and load functions to handle the files.

TJ_Tigger
08-18-2004, 01:00 PM
What about using the Crypto plugin to encrypt the data and when the project starts decrypt the files and load the script.

Brett
08-18-2004, 01:14 PM
OR, here is something else:

You can use the file LuaCompile.exe that is in the attached Zip file to compile a lua script file to lua opcode (binary) and then just use Application.LoadScript to load it in. It will be unreadable to someone browsing the folder but will still read the script into then engine properly (Application.Load automatically knows it is compiled opcodes).

This is a console command line program so you will have to do it from a DOS window (Start > Run > Cmd.exe).

mz241508
04-05-2007, 05:43 AM
That is a great tool, but when you view the output file on a notepad some parts of the code is viewable which can taken.

Is there any other way to make it more secure and unstealable?