Does anyone (particularly Zerted) know the exact version of LUA that SWBF1 or SWBF2 (particularly SWBF2) uses? I know that the LUA system has decompilers, and I think it's just a matter of extracting raw files and then reinserting a proper header, then decompiling, but I'm not sure on the versions. I think I read somewhere that SWBF2 uses 5.0, but I'm fuzzy on that.
*EDIT*
Why oh why did we have forum pruning on in this section? That PSP/PS2/Xbox mod thread is gone, and I really needed some files someone posted to test out LUA decompiling (the PSP scripts for Rebel Raider). There's a luadec.exe (LUA decompiler) demonstration video below. It's not for the faint of heart, but it seems to work.
Teancum wrote:There's a luadec.exe (LUA decompiler) demonstration video below. It's not for the faint of heart, but it seems to work.
But what is it decompiling from, compiled source from luac.exe? It would be of great use if it could decompile from .lvl files, but I don't think that compiled Lua code is just sitting around in .lvl files.
EDIT:
I tried to work a simple file (LinkedTurrets) through THIS which is basically just LuaDec51 with some batch scripts to help end users (it's more than that, but that's not important). I extracted the compiled scripts from mission.lvl with the LVL Extractor, but the output .lub file didn't work through luadec.exe. To make sure, I took the original LinkedTurrets.lua, compiled it, then decompiled it and it worked out fine, so it's not the process I used that was wrong. I also tested the compiled LinkedTurrets.lua to the .lub file that was output from the extractor and while there were similarities, it was not a match.
I'm not saying that LuaDec51 does not work, I'm suggesting that it might not, but that instead this decompiling kitchen doesn't work. There is another luadec.exe for 5.0, but this was the easiest to use, so I tried it first hoping for some back compatibility.
EDIT2:
Looking more into that video, I think I found the source: HERE. The .lub file from that thread has a striking resemblance to the .lub files from the extractor, so it looks like money... if we can get it to work.
Re: LUA versions for SWBF1/2?
Posted: Sat Jul 11, 2009 9:08 am
by [RDH]Zerted
Teancum wrote:I think I read somewhere that SWBF2 uses 5.0, but I'm fuzzy on that.
The topic you linked to says that in its title. If you run luac.exe from the mod tools, it says its v5.0.2. You need to use the v5.0.2 decompiler (LuaDec)
The problem noted so long ago (it might have been said on extract's site instead of GT, I don't remember), was that the number size for swbf2's lua is 4 while the decompiler expected 8 (the decompiler's error message clearly says this). I tried to make the changes a few years ago, but I didn't have the build tools to recompile the decompiler. Now I'm on linux and I do.
I messed with decompiler's config file for a few minutes, then found a different tool that works better. The other tool reconstructs the code, but keeps it coupled with the Lua VM instructions. In theory decompiling with the tool, recompiling with number size 8, and decompiling the result with LuaDec will give us most of the source code back and without the VM instructions. I'm saying most because both tools say they have a few bugs in them. Hopefully, none of the scripts have the complex, unsupported operations. v1.3's code might
I'll mess around with it a little more. If I get it working, I'll post a short tutorial. I've got bunches of stuff to do and don't have time to make any more video tutorials.
Edit:
We can use extract to pull the compiled Lua out of lvl files
We can use ChunkSpy to generate a more readable version of the lub files.
We can use ChunkSpy to recompile the lubs into slightly different profiles (such as to fix the 4->8 number issue). LuaDec fails with the 4->8 number issue on lub files from extract. LuaDec fails with unknown number format on 4->8 rewritten/fixed ChunkSpy recompiled files.
For ChunkSpy to fix the 4->8 issue, one has use the command line option: --rewrite "swbf2" after adding the following code at line 135 in ChunkSpy.lua:
SetupTeams.lua extracted from mission.lvl using extract and processed with ChunkSpy:
Hidden/Spoiler:
[code]Pos Hex Data Description or Code
------------------------------------------------------------------------
0000 ** source chunk: ../../extract/scr_setup_teams.lub
** global header start **
0000 1B4C7561 header signature: "\27Lua"
0004 50 version (major:minor hex digits)
0005 01 endianness (1=little endian)
0006 04 size of int (bytes)
0007 04 size of size_t (bytes)
0008 04 size of Instruction (bytes)
0009 06 size of OP (bits)
000A 08 size of A (bits)
000B 09 size of B (bits)
000C 09 size of C (bits)
000D 04 size of number (bytes)
000E 3BAFEF4B sample number (single)
* chunk platform unrecognized
** global header end **
I can slowly read that, but I'm not sure whats worth trying to recreate the lua for. Other then the v1.3 code, what do we need to extract? Err, I guess the PSP stuff Teancum wants. Anything on the PC side?
Re: LUA versions for SWBF1/2?
Posted: Sat Jul 11, 2009 3:16 pm
by Frisbeetarian
Mav's "The Big L" Lua script was also lost.
Re: LUA versions for SWBF1/2?
Posted: Sat Jul 11, 2009 4:52 pm
by Teancum
It's almost not worth it for that effort. Too bad the video doesn't shed more light on the situation.
Re: LUA versions for SWBF1/2?
Posted: Sat Jul 11, 2009 5:05 pm
by Maveritchell
There are a few scripts of mine that I'd like to get my hands on that I could not otherwise. If there's not a way to easily parse the output from this into SWBF2 script luacode, I won't press too hard to see it done, though.
Re: LUA versions for SWBF1/2?
Posted: Sat Jul 11, 2009 6:42 pm
by Frisbeetarian
Teancum wrote:Too bad the video doesn't shed more light on the situation.
The video sheds plenty of light. It more or less tells us exactly what this guy did to decompile his Worms3D files.
I'm not saying that it's easy (the guy who did this even says that it's "very very very hard"), but I am saying that it seems like they have the same type of problems we have, thus their solution may work. I just need to figure out from where to get that Lua50to51.exe (he says that it's used "for replace Single value to Double value").
About program Lua50to51.exe it my program I writed it long time ago when i have not source of Scripts lua...
You want Lua50to51.exe? Ok I put it here Download Lua50to51.rar
But you should replace only Float values... Now I not need this program, I get original lua scripts from PS2 version.
P.S. Sorry for bad English
AlexBond.
Re: LUA versions for SWBF1/2?
Posted: Sat Jul 11, 2009 11:17 pm
by [RDH]Zerted
That didn't really help me, but thanks for posting the file. Frisbeetarian's going at this from a slightly different approach than me. He might have more success with it.
I did discover using the --brief argument with ChunkSpy provides a much more readable output. Heres a sample below:
If you need to extract any strings or see which functions get called, this format is good enough for that.
Re: LUA versions for SWBF1/2?
Posted: Sat Jul 11, 2009 11:34 pm
by Frisbeetarian
[RDH]Zerted wrote:Frisbeetarian's going at this from a slightly different approach than me.
Right. I PM'd him on his site about this, that's why he posted.
@AlexBond
I appreciate your quick response. I'll see what I can do with it. Thanks!
Re: LUA versions for SWBF1/2?
Posted: Mon Jul 13, 2009 4:42 pm
by Teancum
Sweet, we've got AlexBond's program. That should allow for full decompiling; it may be repetitive and take forever, but we can recover some important stuff. Even still I personally would rather limit what I did with it. All I want to do is decompile the PSP-exclusive gametypes, the 1.3 patch stuff so Zerted can continue his work, and that's about it.
This just means that I can try it his way; I don't know if I'll get anything.
From what I've gathered, much of the problem with decompiling our Lua scripts are the headers. Looking at the first part of each one of our .lub files and one of their .lub files, bits 0-3A are the same with the exception of bit 32 which is 09 in ours instead of 0E. This is why I have hope.
Re: LUA versions for SWBF1/2?
Posted: Sat Aug 07, 2010 10:54 am
by [RDH]Zerted
Any of you guys still have Luadec_preview.avi? All the video links are dead.
Also, we overlooked the comman line arguments of luac.exe. luac.exe -l src_points.lua gives us something close to the brief listing:
I know there aren't many of us interested in decompiling, but in looking through SWBF1 munged files if we could only recreate SWBF1's missionlist.lua we could create PS2 and Xbox expansions for SWBF1 with utter (okay, relative) simplicity. I'm really interested in this because even though SWBF2 is a major resource hog in the PS2/Xbox, SWBF1 runs like a dream and is much, much less resource intensive on consoles (it also looks 100x better on the PS2 than SWBF2). So, that being said I'll be direct. If anyone can recreate missionlist.lua for SWBF1, through decompiling or other means I can (and will) build SWBF1 mods for PS2/Xbox.
Now that being said it ain't been done yet, so you PS2/Xbox users just be patient. In fact, don't expect anything unless you hear that we have a working missionlist.lua.
Re: LUA versions for SWBF1/2?
Posted: Tue May 17, 2011 3:38 am
by [RDH]Zerted
Don't remember reading this page before (though I probably just forgot...). It talks a little bit about how the decompilers go about their broken business: http://www.lucasforums.com/showthread.php?t=163836
Also, eAthenauses lub files, though it's modders mostly decompile those by hand.