FANDOM


  • Hey there,

    Recently TableWiz has been helping me out with lua Modules which has benefitted the Wiki by automating/shortening a lot of processes which would otherwise entail copious amounts of manual hand-typing. However, it seems every page that gets made and uses this module throws up some sort of script error, even though nothing appears to be wrong on the surface.

    Example page: Touring Renault
    I would like to know what this error is and how to rectify it. Failing that, I would like to know if it's possible to hide this category from the page.

      Loading editor
    • For future reference, when you prevent the display of error messages by using #iferror, it makes it harder to identify where the error is coming from; let alone what the error is.

      To hide the category on the pages, you should be able to make Pages with script errors a hidden category. You do this by adding __HIDDENCAT__ to the category page's content.

      There are two things that are contributing to the error.

      1. Your database does not contain an entry for those addons.
      2. Your Lua script does not properly handle situations in which no data is available for the requested addon.

      You can fix the issue for current pages by simply adding entries for them in the database. However, you will have this problem each time there is a new addon and an entry has not yet been added to the database. If you want to avoid this error even when there is no entry, your need to add some if statements so that different instructions are executed if there isn't a entry. Probably something like this:

      function p.ar( frame )
          local performanceData = mw.loadData( 'Module:CarPerformance/data' )
          local performanceModel = frame.args[1]
          local performanceSplit = performanceData[performanceModel]
          if (performanceSplit == nil) then
              return ""
          end
          local tab = mw.text.split( performanceSplit, " ")
       
          return (tab[1])
       
      end

      Since I am a noob with Lua, I am not sure what will be displayed if the split string doesn't have enough parts. Depending on what happens, you may want to add a check for that as well.

        Loading editor
    • or just add or '' to all your "performanceSplit = performanceData[performanceModel]"

        Loading editor
    • Since you are here and this is relevant to the alternative you suggested: what would happen if the return statement asks for something out of index for "tab"?

        Loading editor
    • it will return nil. it's fine, unless you will try to x .. nil or some another operation that forbidden for nil and will throw an exception.

        Loading editor
    • Perhaps I didn't word my question well enough. I know the function will return nil but what I was curious about is what would be displayed on the page.

        Loading editor
    •   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.