User:SerpentofSet: Difference between revisions

Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
I am bad at the game so I edit the wiki
I am bad at the game so I edit the wiki


Below stolen shamelessly from the MediaWiki Scribunto articles
==How to Debug in Scribunto==
 
==Examples==
===Invoking module directly===
Given [[Module:Test]] with the following contents:
<syntaxhighlight lang="lua">
local p = {}
function p.main(frame)
  local args = frame.args
  mw.log("log test")
  return args[1]..args["sep"]..args[2]
end
return p
</syntaxhighlight>
The following invoke call:
<code><nowiki>{{#invoke:Test|a|sep=;|b}}</nowiki></code>
<code><nowiki>{{#invoke:Test|a|sep=;|b}}</nowiki></code>
Can be simulated accurately with the following code in the debug console:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
=p.main(
=p.main(
Line 25: Line 10:
   }
   }
)</syntaxhighlight>
)</syntaxhighlight>
Note that in this example the element in the export table which is being evaluated is called "main".
====Simplified version====
====Simplified version====
If the module you are debugging does not use any [[Extension:Scribunto/Lua_reference_manual#Frame_object|frame object methods]] (such as <code>frame:preprocess()</code>), like the example [[#Invoking module directly|above]], then the frame object analog(?) does not have to be complete, and the debugging code can be simplified into the following:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
=p.main{
=p.main{
Line 34: Line 16:
}</syntaxhighlight>
}</syntaxhighlight>


What's a sandbox
==What's a sandbox==
{{PageRef|Yamato|type=Hero}}
{{PageRef|Yamato|type=Hero}}