-
Notifications
You must be signed in to change notification settings - Fork 20
Lua API
The "Illusion Engine" or now known as "Fusion Engine" uses an extremely powerful and robust programming language called "Lua" for it's game scripts. When you unpack vanilla SDS archives, you will see they are in bytecode. This means they cannot be edited without using another program. Luckily, the Toolkit can decompile the scripts for you. When double-clicking on a lua script (MyScript.lua, MyScript.lua.AP are a few examples), the Toolkit will attempt to decompile the script using a program called 'Unluac'. While this program is not the best at decompiling the bytecode, it does a pretty good job at getting started.
Note that some scripts may not work after being decompiled, and you will have to fix them manually to get them working.
Please note if you know any better Lua bytecode decompilers then please let me know! We will be more than happy to replace Unluac if another decompiler does a better job.
To decompile a Lua script, use the Game Explorer and unpack an SDS. Once you have unpacked an SDS, navigate to the 'extracted' folder of the respective SDS and double click on the Lua script. Refresh the 'Game Explorer' window and you should see the same Lua script, but with a "_d" prefix. The Toolkit does not directly replace the compiled version due to the highly likely change that it will break the SDS. If you want the game to use the decompiled version. Replace the compiled lua script with the "_d" variant.
This is mainly for "Illusion Engine", so Mafia II and Mafia II: Definitive Edition. Some functions will exist and work in Mafia III and Mafia: Definitive Edition, but no documentation was created for the newer games. (Feel free to do so!)
This was originally over at Mafia Scene, but no longer exists on the website. So all credit goes to the original modders who documented all of this information. The best source of information on the Lua API was originally on the Mafia Scene website and somehow lost/removed. Luckily for us, it was all backed up.