On Tue, Apr 2, 2013 at 9:46 AM, Mathieu Stumpf
<psychoslave(a)culture-libre.org> wrote:
Sorry for the noise, but I didn't know where to post this. Please point me
any place more appropriate for this kind of topic if you know one.
https://www.mediawiki.org/wiki/Talk:Lua_scripting is generally a good
place, as is
https://en.wikipedia.org/wiki/Wikipedia:Lua_requests if
you can avoid sounding too off-topic. As for mailing lists, wikitech-l
might be appropriate too.
And the relevant part are:
pron = require( "Module:Pr0n" )
for i=0,99 do
pron.ortho(i) -- fail!
end
Here is the error message:
Erreur Lua dans Module:Pr0n à la ligne 37: attempt to index local 'frame' (a
number value).
Your function expects a frame object,[1] as is required for it to be
called from #invoke, and you're passing it a number.
You can create a new frame object with
mw.getCurrentFrame():newChild.[2] Or, if the only thing you're using
from the frame object is frame.args, you can cheat and call it
something like
pron.ortho( { args = { i } } )
Another option is to make two functions: one which takes a number, and
a second which takes a frame, extracts the number, and calls the
first:
-- This can be called from other modules, test cases, etc
function pron.orthoInternal( number ) {
-- Existing code here
}
-- This wrapper is for calling using {{#invoke:}}
function pron.ortho( frame ) {
return pron.orthoInternal( frame.args[1] )
}
[1]:
https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Fra…
[2]:
https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#fra…
--
Brad Jorsch
Software Engineer
Wikimedia Foundation