Hack 'n' Slash

Hack 'n' Slash

Not enough ratings
Disassembly Dumping
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
13.337 KB
21 Sep, 2014 @ 12:43am
24 Sep, 2014 @ 10:43pm
5 Change Notes ( view )

Subscribe to download
Disassembly Dumping

Description
This mod automatically disassembles all Lua files inside the game's directory and saves a readable dump of these objects in the storage directory. The dump does not match the in-game disassembly visualizer, but is rather a representation of the Lua variable returned by scripts.disassemble(). This should be extremely useful for wannabe modders that have trouble understanding what exactly this function returns.

The functions contained inside this mod can be applied to any Lua variable and should be useful outside of this particular mod, so I invite other modders to reuse them if they need it for inspecting a table with an unknown structure.

This mod contains code borrowed from Noughtceratops's Translation Kit.
7 Comments
Archomeda 27 Oct, 2014 @ 6:27pm 
I posted a list of these functions about a month ago in the discussions . It seems those functions are defined in the Lua scripting engine that's included in the game.

I don't have the script anymore that I used to dump the function list, because they updated the file that I had edited. But yeah, have fun :)
SmashManiac  [author] 26 Oct, 2014 @ 11:03pm 
Indeed, those are defined in metatables which I can't dump safely. Hopefully a full documentation will be released soon. In the meantime, you'll need to inspect the EXE directly.
aschepler 26 Oct, 2014 @ 12:31pm 
Useful, thanks! But this still doesn't seem to show the whole story: for example given an element "instruction" of a "code" subtable, you can do "instruction:GET_OPCODE_NAME()" which returns a string. This must involve some sort of metatable stuff or other magic.

We can see several more of those magic methods being used in Scripts/Disassembly.lua and other files. I wonder what the complete set of magic methods is.
SmashManiac  [author] 24 Sep, 2014 @ 10:50pm 
Small update: Now the mod is dumping everything, so it's possible to easily compare the source code in Data/Scripts to its disassembly.
Archomeda 21 Sep, 2014 @ 2:54pm 
Still easy enough to do it in a reasonable amount of time I see ;)
I can confirm it works. The assembly is way easier to read now! Thanks!
SmashManiac  [author] 21 Sep, 2014 @ 1:09pm 
Good idea Archomeda! This was easier said than done, but I've updated the mod to do so. Now tables with less than 2 elements will appear on the same line, except if it has 1 element that is itself a table.
Archomeda 21 Sep, 2014 @ 8:05am 
Certainly very useful :)
I did this myself as well, but I didn't automate it for all files, only the ones I needed so far. Nicely done!

One small request though, can you change the output of the code tables? At the moment it shows for example:
1 = GETGLOBAL 0 0 {
instruction = number: 5
}
I would like to have it a bit more readable on one line:
1 = GETGLOBAL 0 0 { instruction = number: 5 }
From 3 lines to only 1 line per instruction. Especially with large files this can make a huge difference when scrolling.