Thread Tools Display Modes
05-30-23, 11:40 AM   #1
An Aku'mai Servant
Join Date: Dec 2022
Posts: 33
How to dump a table to the screen

Is there a lua equivalent to var_dump from

Basically I wanting to know what's inside a table.
  Reply With Quote
05-30-23, 12:16 PM   #2
I did that?
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,733
/dump <table name>
but the table has to be global.

Otherwise, in code you could:
Lua Code:
  1. DevTools_Dump(table)

Edited after remembering DevTools had changed from it's original incarnation thanks to wardz and LudiusMaximus.
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-30-23 at 04:24 PM.
  Reply With Quote
05-30-23, 12:18 PM   #3
A Deviate Faerie Dragon
wardz's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 17
/dump table
/run DevTools_DumpCommand("table")
/run DevTools_Dump(table)

Edit; might need UIParentLoadAddOn("Blizzard_DebugTools") if not using /dump

Last edited by wardz : 05-30-23 at 12:30 PM.
  Reply With Quote
05-30-23, 03:16 PM   #4
A Rage Talon Dragon Guard
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 316
When I want to search recursively for strings in tables, I use this function:

Lua Code:
  1. local function PrintTable(t, indent)
  2.   assert(type(t) == "table", "PrintTable() called for non-table!")
  4.   local indentString = ""
  5.   for i = 1, indent do
  6.     indentString = indentString .. "  "
  7.   end
  9.   for k, v in pairs(t) do
  10.     if type(v) ~= "table" then
  11.       if type(v) == "string" then
  12.         print(indentString, k, "=", v)
  13.       end
  14.     else
  15.       print(indentString, k, "=")
  16.       print(indentString, "  {")
  17.       PrintTable(v, indent + 2)
  18.       print(indentString, "  }")
  19.     end
  20.   end
  21. end
  23. PrintTable(tableToPrint, 1)
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
05-31-23, 12:45 AM   #5
A Pyroguard Emberseer
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,278
The built-in DevTools also supplies a /tableinspect command that allows you to navigate tables in an inspection window.
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » How to dump a table to the screen

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off