[ LUA Tool ] Dump to HTML

Discussion in 'Programming' started by GregBlast, Sep 19, 2013.

  1. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    Description

    I recently found some code that dumps the contents of a table and its sub-tables as HTML content into either the console or more logically...an HTML file. This can be pretty handy especially because the constructed HTML file allows you to expand / collapse tables and jump to a parent or sub-table from a link.

    HtmlTools-DumpHtml.png


    Installation





    • Extract the file htmlTools.lua into your [game path]\lua folder
    • open [game path]\lua\system\main.lua
    • below console = require("console") insert the following line
      Code:
      htmlTools = require("htmlTools")
    • open [game path]\lua\vehicle\default.lua
    • below require("utils") insert the same line
      Code:
      htmlTools = require("htmlTools")


    How to use



    • in game open your console and select BNGS or BNGV in the bottom-left drop-down (either BNGS for System or BNGV for Vehicle)
    • assuming you want to dump the global table _G to a file named dumpSystem.html in the game's root folder type the following code
      Code:
      htmlTools.dumpToFile( _G, "dumpSystem" )


    Notes



    • I advise you not to dump the global environment (_G) of the Vehicle LUA because it's too big and will hang your game until it crashes with an Out of memory exception.
    • unlike the global dump and dumpToFile functions that you may already know of this doesn't dig into metatables. Also don't expect it to show you the contents of userdata ;).
    • the names showed in your browser are not ideal as they are composed of a table ID reference followed by its first element name but just expand it with the + and you'll get it
    • As I said I didn't make the code that does this I'm just providing it as it's under the same licence as LUA. Creator credits are still in at the top of the file. I simply made a module out of it to limit its use and not pollute the global environment.
     

    Attached Files:

    #1 GregBlast, Sep 19, 2013
    Last edited: Sep 20, 2013
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice