Help:Lua debugging: Difference between revisions

Content deleted Content added
Modifying the code: Rephrased a few sentences and made the headers more understandable and meaningful in the header structure.
Line 25:
To see the value of a variable in a single point of the module:
 
====ModifyingTo see the value of a variable by modifying the code====
The <code>error()</code> function (forcan be used to show the value of a variable at any point in the module) can be used. So to know the avalue variableof (nameda herevariable <code>var</code>) value,at onlya addingcertain a linepoint in the modulecode, withadd the line <code>error(var)</code> isat requiredthat point.
 
But inIn the case that the variable wasis a table (let's call the variable <code>tab</code>), in the next explanation) <code>mw.dumpObject(tab)</code> willcan be used or,to ifshow itthe table. If the variable does not have nested tables, <code>table.concat (tab, ',')</code> can also be used as parameter in the <code>error()</code> function, i.e. <code>error(table.concat(tab, ','))</code>.
 
====Without To see the value of a variable without changing the code ====
To obtain variables and values returned from functions (not local in both cases) the "Debug console" can be used. The "Debug console" appears below in the module page (when it is in edit mode). Then <code>mw.log</code>, <code>mw.logObject</code>, and <code>=</code> can be used. Let's see its usefulness in the next example:
{{#tag:syntaxhighlight|