LUA versions for SWBF1/2?
Moderator: Moderators
- Teancum
- Jedi Admin

- Posts: 11080
- Joined: Wed Sep 07, 2005 11:42 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Indiana
LUA versions for SWBF1/2?
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.
http://www.youtube.com/watch?v=Qz4LDs18-nY
*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.
http://www.youtube.com/watch?v=Qz4LDs18-nY
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: LUA versions for SWBF1/2?
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.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.
http://www.gametoast.com/forums/viewtop ... =27&t=2572
This talks about which version each game uses, but the first post is gone, so I'm not sure why it's still in the FAQ.
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.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: LUA versions for SWBF1/2?
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)Teancum wrote:I think I read somewhere that SWBF2 uses 5.0, but I'm fuzzy on that.
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:
Hidden/Spoiler:
Hidden/Spoiler:
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: LUA versions for SWBF1/2?
Mav's "The Big L" Lua script was also lost.
- Teancum
- Jedi Admin

- Posts: 11080
- Joined: Wed Sep 07, 2005 11:42 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Indiana
Re: LUA versions for SWBF1/2?
It's almost not worth it for that effort. Too bad the video doesn't shed more light on the situation.
- Maveritchell
- Jedi Admin

- Posts: 7366
- Joined: Mon Aug 21, 2006 11:03 pm
Re: LUA versions for SWBF1/2?
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.
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: LUA versions for SWBF1/2?
The video sheds plenty of light. It more or less tells us exactly what this guy did to decompile his Worms3D files.Teancum wrote:Too bad the video doesn't shed more light on the situation.
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").
-
AlexBond
- Posts: 1
- Joined: Sat Jul 11, 2009 9:16 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Belarus
- Contact:
Re: LUA versions for SWBF1/2?
Full video http://rapidshare.com/files/139045930/L ... w.rar.html
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.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: LUA versions for SWBF1/2?
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.
I did discover using the --brief argument with ChunkSpy provides a much more readable output. Heres a sample below:
Hidden/Spoiler:
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: LUA versions for SWBF1/2?
Right. I PM'd him on his site about this, that's why he posted.[RDH]Zerted wrote:Frisbeetarian's going at this from a slightly different approach than me.
@AlexBond
I appreciate your quick response. I'll see what I can do with it. Thanks!
- Teancum
- Jedi Admin

- Posts: 11080
- Joined: Wed Sep 07, 2005 11:42 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Indiana
Re: LUA versions for SWBF1/2?
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.
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: LUA versions for SWBF1/2?
This just means that I can try it his way; I don't know if I'll get anything.Teancum wrote:Sweet, we've got AlexBond's program.
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.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: LUA versions for SWBF1/2?
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:
Also, we overlooked the comman line arguments of luac.exe.
luac.exe -l src_points.lua gives us something close to the brief listing:
Hidden/Spoiler:
- AceMastermind
- Gametoast Staff

- Posts: 3285
- Joined: Mon Aug 21, 2006 6:23 am
- Contact:
Re: LUA versions for SWBF1/2?
Download it and watch it offline:[RDH]Zerted wrote:Any of you guys still have Luadec_preview.avi? All the video links are dead.
Luadec_preview.rar
OR
Watch it online:
- Teancum
- Jedi Admin

- Posts: 11080
- Joined: Wed Sep 07, 2005 11:42 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Indiana
Re: LUA versions for SWBF1/2?
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.
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.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: LUA versions for SWBF1/2?
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, eAthena uses lub files, though it's modders mostly decompile those by hand.
Also, eAthena uses lub files, though it's modders mostly decompile those by hand.
