taw / etwng

Next Generation Modding Tools for Empire Total War (and other Total War games)
36 stars 27 forks source link

Lua Decompile/Recompile #18

Closed Co1dfront closed 2 years ago

Co1dfront commented 2 years ago

I am using your version of the luacdec in an attempt to decompile, edit, and then recompile lua code for NTW.

First, the cmd method you have listed doesn't work if you add $, therefore, the command I am using is "java - jar unluac_2015_06_13.jar xxx.luac > xxx.lua"

Second, the file that is decompiled comes out with CRLF ends, so I change that in VScode to LF (saw that you gave this advice to someone convertering UI files, so I have tried both endings with the lua files)

Third, do you have a recommended method for recompiling them? I have this boot leg luac5.1.exe (as the offical lua cite no longer has the original lua5.1 binaries) I have been using?

All lua files that I decompile and recompile, whether that be vanilla or personal files, end up freezing the game on a gray screen. Any help or advice you could give would be great. Thank you for your time

taw commented 2 years ago

The $ just means command prompt, it's to show what's the input, and what's command output.

CRLF vs LF really shouldn't matter for anything you do with Lua files.

Anyway, to recompile, for Empire you'd need to apply lua_etw.diff - basically to replace doubles with floats. I never even tried NTW, but it's probably something similar. That was the only patch necessary. Obviously it was 32-bit back then, so don't accidentally compile it for 64-bit.

You still need the right lua version. If you do everything right, .luac headers should match, they contain all relevant information.

It's been so long time ago, that I don't really recall everything. Hopefully that helps.

Co1dfront commented 2 years ago

Thank you for your quick response,

I understand that unluac uses lua_etw.diff to convert the doubles to floats, and you are suggesting that I might need to require it again for recompile?

I am at the moment using lua version from the 5.1.4 win32 bin, as unluac uses 5.1.4.

Thank you again for your time.

taw commented 2 years ago

Yeah, you need to get it same on recompile. Here's something about Luac headers:

Six system parameters. On x386 machines they mean: little-endian, 4-byte integers, 4-byte VM instructions, 4-byte size_t numbers, 8-byte Lua numbers, floating-point. These parameters must all match up between the bytecode file and the Lua interpreter, otherwise the bytecode is invalid.

ETW used 4 byte floats not 8, for its luac.

taw commented 2 years ago

Hopefully this is resolved now. Feel free to reopen if not.