Wikimedia

[Lua task #03] Create your own Lua module on English Wikipedia

To work on this, you must have successfully finished the task "[Lua task #02] Use Lua on English Wikipedia" before!

You can write your own Lua functions using your sandbox module to try out code. You can then use your sandbox to call a function from your module and see how well it works.

  1. Read the "Introduction - Getting started" + "Introduction - Module structure" sections. Make sure you understand that the module begins by defining an empty table, then defines functions (adding them to the table), and finally returns the table.

  2. Copy the following questions into your sandbox (not your module sandbox): Which letter is conventionally used in Scribunto modules to hold the table of functions? What keyword marks the start of a function definition? What keyword marks the end of a function definition?

  3. Write your answers to the 3 questions in your sandbox.

  4. In your module sandbox you should just have a comment (-- Google Code-in 2017, Introduction to Lua in Wikipedia). On a new line write another similar comment with the name of this task. Save the module.

  5. Below that comment, copy all of the code needed to produce the hello function from the example Include the initial line beginning local ..., and the final line beginning return .... Save the module.

  6. Work out what you need to write in your sandbox in order to call the hello function from your module sandbox. Write that in your sandbox and test it by previewing the edit. When you have no errors, save the sandbox.

Task tags

  • lua
  • scribunto

Students who completed this task

Chen Xinpeng, Gabriel CH Lee, Chen Wuyang, Sathvik Hebbar, Om Desai, Cliff Chen, Tarun Prasad, suufi, Priyanshu Ahuja, Gabe Mitnick, Gammaburst_3000, PokkPol, Yajn Bollapragada, Sanath, Kid116, Linda Thelen, Jan Nowosielski, C. F. Fairfeld, Sai, Liza Amini, OHM OMAR, TimurO, Rafid Aslam, srflp

Task type

  • code Code
close

2017