Search code examples
luamediawikiscribunto

Mediawiki scribunto lua module do not know builtin functions


I am having a problem with calling Lua built-in functions using Scribunto.

I created basic module Module:Item

local p = {}; 
function p.test(frame)
    print("Hello World!")
end
return p

Which I call in different page as {{#invoke: Item | test}} and I receive a following error:

Lua error in Module:Item at line 3: attempt to call global 'print' (a nil value).
Backtrace:
    1. (tail call): ?
    2. Module:Item:3: in function "chunk"
    3. mw.lua:511: ?
    4. (tail call): ?
    5. [C]: in function "xpcall"
    6. MWServer.lua:99: in function "handleCall"
    7. MWServer.lua:313: in function "dispatch"
    8. MWServer.lua:52: in function "execute"
    9. mw_main.lua:7: in main chunk
    10. [C]: ?

Since print is Lua built-in function I have the feeling the problem will be somewhere in setting on the pc. However, when I imported wiki Infoboxes, they are working OK.

Versions:

Linux Mint Tara - Cinnamon based on ubuntu 18

MediaWiki 1.31.7

Scribunto (106fbf4) 17:24, 15 May 2018

Lua 5.1.5

Any help pointing where the problem can be is highly appreciated.


Solution

  • Scribunto intentionally doesn't include print. The "Removed functions and packages" section in its manual says this about it:

    This was discussed on wikitech-l and it was decided that it should be omitted in favour of return values, to improve code quality. If necessary, mw.log() may be used to output information to the debug console.