PtokaX forum

PtokaX => Support => Topic started by: blackwings on 20 June, 2004, 20:02:05

Title: compileing scripts
Post by: blackwings on 20 June, 2004, 20:02:05
I wonder if it's easy to complie lua scripts? I was thinking of comling some of my script so that my hub might get a little bit faster.
Title:
Post by: VidFamne on 20 June, 2004, 20:08:41
About precompiling scripts.
Its IMHO only when you read in the scripts its faster.
The script engine in ptokax will compile the script, when you start the script.
This is what I thought about it.
Correct me if I'm wrong :D
Title:
Post by: plop on 20 June, 2004, 21:41:10
QuoteOriginally posted by VidFamne
About precompiling scripts.
Its IMHO only when you read in the scripts its faster.
The script engine in ptokax will compile the script, when you start the script.
This is what I thought about it.
Correct me if I'm wrong :D
ptokax (and same for everything else which uses lua scripts) do indeed compile them on start.
just by using a precompiler you get a bit more speed.
lua is a character interpred language, by precompiling you strip all the blanc spaces, this is what makes it faster.
but i bet wombat can explain it better.

the way 2 use it:
luac -o outputfilename.lua inputfilename.lua

plop
Title:
Post by: Corayzon on 21 June, 2004, 02:25:20
im not sure exactly what im asking, but ...

how would you go bout compiling scripts so there unreadable by hub owners using them?

and no, im not making cslave compiled, just wanted to know =]

noza
Title:
Post by: NotRabidWombat on 21 June, 2004, 07:41:27
Compiling is the process of changing human readable code into machine code.

The luac man page answers your question best:
"The main advantages of pre-compiling chunks are: faster loading, protecting source code from user changes, and off-line syntax error detection."

Although, JenZen and I experimented with altering compiled lua and found it was fairly easy, even with the most basic knowledge of the lua opcodes.

The other two advantages are good for a hub loading many small scripts (that may restart scripts often) but there are few advantages for large scripts to compile. It's just a false sense of security. Besides, we've all seen what happens here when someone tries to take credit for someone else's work ;-)

An interesting tid bit of information, you can combine all compiled lua files into one large file by appending them to each other. I would assume that order matters. *edit* with scripts that load other scripts */edit*

Read more about luac here:
http://www.lua.org/manual/4.0/luac.html

-NotRabidWombat
Title:
Post by: NotRabidWombat on 21 June, 2004, 07:44:11
"how would you go bout compiling scripts so there unreadable by hub owners using them?"

Surprisingly, compiled lua is readable when put into opcodes (to a programmer). JenZen and I also searched for a method to encrypt the file and perform a checksum at the beginning, but gave up after determing there was no productive way to use such a feature.

-NotRabidWombat
Title:
Post by: radical on 21 June, 2004, 19:10:46
http://forums.relicnews.com/showthread.php?t=23183 (http://forums.relicnews.com/showthread.php?t=23183)
Title:
Post by: blackwings on 21 June, 2004, 22:19:07
QuoteOriginally posted by plop
the way 2 use it:
luac -o outputfilename.lua inputfilename.lua

plop

And which program should I use?

And radical, I wanted to compile files, not decompile.
Title:
Post by: NotRabidWombat on 21 June, 2004, 23:13:04
luac.exe (Compiled from Lua 4.0x)

plop, is kind enough to host it

http://www.plop.nl/lua_tools/luac_4.0.zip

-NotRabidWombat
Title:
Post by: NotRabidWombat on 22 June, 2004, 07:21:11
Actually, I am incorrect.

I neglected what section this thread was in. If you are compiling for BCDC++ lua, you will want the luac binary from the lua website (ver 5.x).

-NotRabidWombat
Title:
Post by: blackwings on 22 June, 2004, 10:03:06
QuoteOriginally posted by NotRabidWombat
Actually, I am incorrect.

I neglected what section this thread was in. If you are compiling for BCDC++ lua, you will want the luac binary from the lua website (ver 5.x).

-NotRabidWombat

No, I meant the script I use for my hub. Anyway, there are only two sections that fit to this thread, this section or the "Help with Scripts" section. But I happend to choose this section of those two.