Help:Extensions/Scribunto/Usage

From Dota 2 Wiki
Jump to: navigation, search
 
 
Usage
 
 
For information on how to code in Lua look at the reference manual.
Illusory Orb icon.png
▶️ We are in accord.
This page has been marked for an open review.
Please see the discussion pages for additional information, your opinion is welcome.

This page attempts to give some guidelines as to when modules should be used.

Introduction[edit]

Modules are generally faster than templates. However, some considerations should be put into whether using one is worth it.

The good[edit]

See also: The Good
Performance 
In 99% of cases, a module will perform better than an equivalent template.
Capability 
Many things that can't be done in templates are possible in modules.
Readability 
For logic based operations (e.g. Module:Calculate) and large templates the Lua code is much more readable than an equivalent template.

The bad[edit]

See also: The Bad
Editability 
Editing modules requires some basic programming knowledge and knowledge of Lua. This makes them hard to change/update for many users.
Complexity 
Modules take away some of the simplicity that makes MediaWiki and the template system great.

The ugly[edit]

See also: The Ugly
  • TBD

Guidelines[edit]

Only use a module if absolutely needed.

Examples[edit]

Below are a couple of examples that would justify using a module.

  1. Complicated logic.
  2. Error avoidance.
  3. Large #switch statements.
  4. Multiple (possibly nested) #cargo_querys.