[TOOL] XPL (LuaJIT) files decompiler
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
-
- Posts: 1002
- Joined: Fri, 13. Jan 12, 19:09
Ok, there is a new version (v0.1.2, the Download link is updated) with most of problems fixed - at least now you may start a new or continue a game with all the UI recompiled. It's even playable to some degree, but some problems are still here: A broken map, A broken reticle and finally broken buttons. The most crucial problem is obviously a targeting system - there is no selection boxes too, the second problem seems to do something with sized.
P.S. And, BTW, there are scrips I'm using to automate the process on Windows (on Linux I have a cool Unix shell to do the same, but much easier. Sadly I have to iterate on Windows too, because constantly rebooting will be too much)
Update: NVM the targeting system. I was trying to recompile old xpls (1.22) and use the result with 1.23. EgoSoft had changed some stuff, including a few global functions removed and presentations changed, so it wasn't working. But the size issue still sticks.
P.S. And, BTW, there are scrips I'm using to automate the process on Windows (on Linux I have a cool Unix shell to do the same, but much easier. Sadly I have to iterate on Windows too, because constantly rebooting will be too much)
Update: NVM the targeting system. I was trying to recompile old xpls (1.22) and use the result with 1.23. EgoSoft had changed some stuff, including a few global functions removed and presentations changed, so it wasn't working. But the size issue still sticks.
-
- Posts: 1002
- Joined: Fri, 13. Jan 12, 19:09
- Fumblesneeze
- Posts: 75
- Joined: Tue, 26. Nov 13, 10:07
Great stuff there. Can't wait to see what people can come up with using this.
Did you get any info from egosoft whether you can put the sources into github?
Did you get any info from egosoft whether you can put the sources into github?
Streaming while writing mods: twitch.tv/fumblesneeze
Thanks for this, man. I can now mod UIs (see here for a WIP of my UI modding adventures).
It looks like the latest git clone of this Lua decompiler/disassembler can't operate on 'ui/addons/gameoptions/gameoptions.xpl' from X:R 2.0. It throws this traceback instead:
Code: Select all
$ python3.3 main.py gameoptions.xpl > gameoptions.lua
Traceback (most recent call last):
File "main.py", line 123, in <module>
retval = main()
File "main.py", line 104, in main
ljd.ast.unwarper.unwarp(ast)
File "/tmp/ljd/ljd/ast/unwarper.py", line 36, in unwarp
_run_step(_unwarp_ifs, node)
File "/tmp/ljd/ljd/ast/unwarper.py", line 43, in _run_step
statements.contents = step(statements.contents, **kargs)
File "/tmp/ljd/ljd/ast/unwarper.py", line 161, in _unwarp_ifs
_unwarp_if_statement(start, body, end, end)
File "/tmp/ljd/ljd/ast/unwarper.py", line 968, in _unwarp_if_statement
then_blocks = _unwarp_ifs(then_body, then_body[-1], topmost_end)
File "/tmp/ljd/ljd/ast/unwarper.py", line 161, in _unwarp_ifs
_unwarp_if_statement(start, body, end, end)
File "/tmp/ljd/ljd/ast/unwarper.py", line 937, in _unwarp_if_statement
topmost_end)
File "/tmp/ljd/ljd/ast/unwarper.py", line 1017, in _extract_if_expression
false, end_i = _search_expression_end(expression, falses)
File "/tmp/ljd/ljd/ast/unwarper.py", line 1049, in _search_expression_end
assert false is not None
AssertionError
-
- Posts: 1
- Joined: Wed, 25. Jun 14, 12:37
hi!I Have a Error on LuaJit2.0.1 like this!
E:\tools\ljd-0.1.3>python main.py resNPC.lua.out
Traceback (most recent call last):
File "main.py", line 123, in <module>
retval = main()
File "main.py", line 77, in main
header, prototype = ljd.rawdump.parser.parse(file_in)
File "E:\tools\ljd-0.1.3\ljd\rawdump\parser.py", line 34, in parse
r = r and _read_prototypes(parser, parser.prototypes)
File "E:\tools\ljd-0.1.3\ljd\rawdump\parser.py", line 72, in _read_prototypes
if not ljd.rawdump.prototype.read(state, prototype):
File "E:\tools\ljd-0.1.3\ljd\rawdump\prototype.py", line 52, in read
r = r and _read_constants(parser, prototype)
File "E:\tools\ljd-0.1.3\ljd\rawdump\prototype.py", line 140, in _read_constan
ts
return ljd.rawdump.constants.read(parser, prototype.constants)
File "E:\tools\ljd-0.1.3\ljd\rawdump\constants.py", line 31, in read
r = r and _read_complex_constants(parser, constants.complex_constants)
File "E:\tools\ljd-0.1.3\ljd\rawdump\constants.py", line 59, in _read_complex_
constants
complex_constants.append(string.decode("ascii"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd8 in position 6: ordinal
not in range(128)
Traceback (most recent call last):
File "main.py", line 123, in <module>
retval = main()
File "main.py", line 77, in main
header, prototype = ljd.rawdump.parser.parse(file_in)
File "E:\tools\ljd-0.1.3\ljd\rawdump\parser.py", line 34, in parse
r = r and _read_prototypes(parser, parser.prototypes)
File "E:\tools\ljd-0.1.3\ljd\rawdump\parser.py", line 72, in _read_prototypes
if not ljd.rawdump.prototype.read(state, prototype):
File "E:\tools\ljd-0.1.3\ljd\rawdump\prototype.py", line 52, in read
r = r and _read_constants(parser, prototype)
File "E:\tools\ljd-0.1.3\ljd\rawdump\prototype.py", line 140, in _read_constan
ts
return ljd.rawdump.constants.read(parser, prototype.constants)
File "E:\tools\ljd-0.1.3\ljd\rawdump\constants.py", line 31, in read
r = r and _read_complex_constants(parser, constants.complex_constants)
File "E:\tools\ljd-0.1.3\ljd\rawdump\constants.py", line 59, in _read_complex_
constants
complex_constants.append(string.decode("ascii"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd8 in position 6: ordinal
not in range(128)
Failed to read prototype
Many files cannot be decompiled and return such error:
Code: Select all
c:\ljd>python main.py helptext.xpl > helptext.lua
Failed to read prototype
-
- Posts: 80
- Joined: Sun, 23. Sep 12, 20:29
Nice work nord. I've used luadec with custom headers to mod tropico games before, and indeed I have noticed there are some problems with figuring out relations with local variables, and sometimes it simply cannot figure out previous functions in the stack. Would be great if we have a better LUA decompiler sometime =]
Code: Select all
D:\Programy\Python34>python main.py FruitUtil.luc > FruitUtil.lua
Traceback (most recent call last):
File "main.py", line 123, in <module>
retval = main()
File "main.py", line 85, in main
ast = ljd.ast.builder.build(prototype)
File "D:\Programy\Python34\ljd\ast\builder.py", line 28, in build
return _build_function_definition(prototype)
File "D:\Programy\Python34\ljd\ast\builder.py", line 49, in _build_function_definition
node.statements.contents = _build_function_blocks(state, instructions)
File "D:\Programy\Python34\ljd\ast\builder.py", line 71, in _build_function_blocks
_establish_warps(state, instructions)
File "D:\Programy\Python34\ljd\ast\builder.py", line 175, in _establish_warps
block.warp, shift = _build_warp(state, block.last_address, warp)
File "D:\Programy\Python34\ljd\ast\builder.py", line 198, in _build_warp
return _build_numeric_loop_warp(state, last_addr, last)
File "D:\Programy\Python34\ljd\ast\builder.py", line 318, in _build_numeric_loop_warp
warp.body = state._warp_in_block(destination)
File "D:\Programy\Python34\ljd\ast\builder.py", line 22, in _warp_in_block
block = self.block_starts[addr]
KeyError: -32718
-
- Posts: 45
- Joined: Thu, 3. Oct 13, 19:49
Re:
Now there is an easy-to-use online Lua decompiler.
Last edited by MagixJonsn on Mon, 4. Jan 21, 11:50, edited 1 time in total.
-
- Moderator (English)
- Posts: 3230
- Joined: Mon, 14. Jul 08, 13:07
Re: Re:
While progress is certainly a good thing, I wouldn't say it's worth waking up a 5-and-a-half year old thread, replying to a person last seen three years past, ony to acknowledge that.