This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
クデル's profile picture

LUAC binary files and CC

Started by クデル, 08 July 2016 - 08:43 AM
クデル #1
Posted 08 July 2016 - 10:43 AM
I have been fiddling with luac recently, and I decided to try and execute a binary file created by it using dofile, however it likes to just throw a Java Heap Space error. Am I misinformed, or this is impossible to do within CC?
LBPHacker #2
Posted 08 July 2016 - 11:20 AM
It's not impossible, you can use string.dump to dump a function and loadstring the dump back into a function. On never versions of CC though, you only have load (which you would call with the dump and a string "b" as the third parameter) and you get a Lua-level error, something like "binary chunk loading is prohibited", but you can get around that with a modified bios.lua.

If you "compile" a Lua source with luac, it'll dump bytecode compatible with the Lua library it was built with. The last time I checked, the bytecode of the official implementation of the Lua library is incompatible with LuaJ's bytecode, so that might be why you get Java-level errors. I get a NullPointerException when I try to loadstring("\27Lua"), so it's not too well protected, you can easily get it to throw a Java-level error with invalid bytecode.
Edited on 08 July 2016 - 09:21 AM