Module:scripts: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 312: Line 312:
--[==[Finds the script whose code matches the one provided. If it exists, it returns a {{lua|Script}} object representing the script. Otherwise, it returns {{lua|nil}}, unless <span class="n">paramForError</span> is given, in which case an error is generated. If <code class="n">paramForError</code> is {{lua|true}}, a generic error message mentioning the bad code is generated; otherwise <code class="n">paramForError</code> should be a string or number specifying the parameter that the code came from, and this parameter will be mentioned in the error message along with the bad code.]==]
--[==[Finds the script whose code matches the one provided. If it exists, it returns a {{lua|Script}} object representing the script. Otherwise, it returns {{lua|nil}}, unless <span class="n">paramForError</span> is given, in which case an error is generated. If <code class="n">paramForError</code> is {{lua|true}}, a generic error message mentioning the bad code is generated; otherwise <code class="n">paramForError</code> should be a string or number specifying the parameter that the code came from, and this parameter will be mentioned in the error message along with the bad code.]==]
function export.getByCode(code, paramForError, disallowNil, useRequire)
function export.getByCode(code, paramForError, disallowNil, useRequire)
-- Track uses of paramForError, ultimately so it can be removed, as error-handling should be done by [[Module:parameters]], not here.
if paramForError ~= nil then
require("Module:debug/track")("scripts/paramForError")
end
if code == nil and not disallowNil then
if code == nil and not disallowNil then
return nil
return nil

Navigation menu