Content deleted Content added
→See also: ce |
new key for Category:Module help: "Debugging" using HotCat |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1:
{{WikiProject Lua header}}
This help-page, '''Help:Lua debugging''', explains issues of writing [[Lua (programming language)|Lua script]] and [[debugging]] the [[source code]], to remove errors or improve performance. Because Lua is a "semi-compiled" interpreted language, it does not prescreen for all common syntax errors, nor detect misspelled variables, which are only found at runtime when seeing the "{{Script error}}" message. Also, unlike [[wp:template]]s which can be run interactively by edit-preview, the Lua script must be tested by show-preview (or run preview) of another page which uses a template which <code>#invoke</code>
Other pre-compiled, or semi-compiled, languages can pinpoint the line number, or code phrase, where a syntax error, or undefined variable name, has been detected; however, that processing can require extra time to perform. Instead, it might be possible to use a [[lexical analysis]] tool, specifically for Lua script, to better detect and pinpoint misspelled variables or logic errors in Lua source code.
Line 40:
! Request !! Returned value
|-
| {{
|-
| {{
|-
| {{
|-
| {{
|-
| {{
table#1 {
:4,
:5,
}
}}
|-
| {{
|-
| {{
|}
Line 84 ⟶ 85:
=== Small caveat: The case of the wrong case ===
Wikipedia has a small perversion regarding page name casing: it will convert the first character of a page name to uppercase, regardless of the way it was entered. To compensate, it also converts the first letter of a template (when transcluded) and module (when invoked) to uppercase. however, this does not extend to the modules stored in User: namespace viewed through the special [[Template sandbox]], because in the sandbox "the first letter" is not the first letter any more. Here is an actual example: for real modules, let's say [[Module:String]], mediawiki software will allow you to use
{|class="wikitable"
|-
! wikitext !! result
|-
|
|-
|
|}
Line 114 ⟶ 115:
=== IDE ===
Running your code through an IDE is helpful for its text highlighting features, which can help you quickly spot syntax errors. Any IDE with the ability to install a Lua text highlighting plugin should work. This could be as simple as [[Notepad++]] (with Lua selected from the language menu) or as full-featured as [[Visual Studio Code]].
=== Step debugger ===
Step debugging is a powerful tool that allows you to step through code one line at a time, and hover over variables to see their contents at the time of execution. IDEs that easily support Lua step debugging include [[ZeroBrane Studio]], and [[IntelliJ IDEA]] with
=== RegEx ===
Line 133 ⟶ 134:
[[Category:Wikipedia how-to]]
[[Category:Wikipedia text help]]
[[Category:
|