• local LuaInfobox = {}
    local HF = require( "Module:HF" )
    function LuaInfobox.FormatImage( field, vars )
        local imagePath = field.Value
        if HF.isempty( imagePath ) then
            return ""
            local prefix = string.sub( imagePath, 1, 5 ) == "File:" and "File:" or ""
            return "[[" .. prefix .. imagePath .. "]]"
    return LuaInfobox
     | 0:Theme = fluid | 0:CustomModule = Module:Test
     | 1:Type = Title
     | 1:Value = {{{ Name | {{PAGENAME}} }}}
     | 2:Type = MainImage
     | 2:Value = {{{ Image | Infobox_Image.png }}}
     | 2:ValueMethod = FormatImage

    I'm trying to make InfoboxBuilder require Module:Test and to call LuaInfobox.FormatImage method on Template:Infobox, but can't get around to.

    local field = { ["Value"] = "test.png" }
    local vars
    =LuaInfobox.FormatImage( field, vars )

    Entering above in the console throws an error: Error in the console, line 7: attempt to index global 'LuaInfobox' (a nil value).

      Loading editor
    • As a note, your invocation error seems to be more related to passing a null value. I did not get the same error you are reporting.

      However, I strongly suggest that you use Portable Infoboxes rather than Lua InfoboxBuilder, which is no longer supported. Additionally, the function you are building in Lua is native to Portable Infoboxes.

        Loading editor
    • Thank you for the reply. Up until a little while ago I was against using PI, thinking source edit mode was not available in it. (It might be helpful if somebody could add some lines on w:c:portability:Help:PortableInfoboxes about how to switch between Builder and Source mode.) That switch button was lurking in the right bottom corner...

      Why not using PI knowing that I have good control of the markup? Time to give it a taste.

        Loading editor
    • A FANDOM user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message
Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+