[14:21:50] So, I'm looking how to reuse a lua module in another... [14:21:59] If something is defined local, it's not going to be reuseable, is it? [14:22:46] Basically... From https://en.wikipedia.org/wiki/Module:Authority_control [14:22:58] I want to reuse most of it, but only replace/override conf [14:25:00] i'm slightly confused why most of the functions in that... are defined local, and not put into p [14:54:34] anomie: ^ got time for a lua/scribunto question? :) [14:54:47] The developer in me doesn't like the copy paste en mass [14:56:38] Reedy: Anything that's not in the returned table ("p" in that case) is basically the equivalent of being "private" in PHP. If you want to export it, put it into 'p'. You could also refactor the bits into a helper module that isn't intended to be called directly, then use that from the existing module and from your module. [14:57:59] Scribunto mostly doesn't care what's returned in "p", as long as it's something that can be passed from Lua→PHP. [15:05:55] does that mean I can just require() the other module... Then call p.function()? [15:09:15] iirc it's othermod = require(...) othermod.function() [15:09:33] that'd make sense :) [15:09:38] * Skizzerz should check that though [15:10:32] yep, it's that :) [15:10:34] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#require [15:10:55] aha, cheers [15:11:01] that should allow me to remove most of the copypasta [15:11:57] * Skizzerz should really finish up pyscribunto... it's like halfway done [15:13:50] Skizzerz: Any idea how to pass frame across? :P [15:14:06] pass it as a param to the function? [15:14:36] where from? [15:14:52] do I need to stick the require etc inside a function to be called from the template caller? [15:14:59] the re-used module has... function p.authorityControl( frame ) [15:15:10] currently.. In the other I have [15:15:10] local p = require( 'Module:Authority control' ) [15:15:11] p.authorityControl() [15:15:22] just passing frame makes it complain [15:15:24] if you put your require at module scope, the variable you assign it to should be available in all functions of your module [15:15:45] https://en.wikipedia.org/wiki/Module:Authority_control [15:15:48] https://en.wikipedia.org/wiki/Module:Authority_control_painting [15:15:49] (since p is the de facto export name, I'd suggest against aliasing the required module as "p") [15:16:04] oh [15:16:54] is painting the one you're working on? [15:16:56] yup [15:17:30] I don't see how what you're trying to do is going to work without modifying the original module [15:17:35] feel free to edit it... it's got some usages, but not a huge amount [15:18:22] lua's require isn't like PHP's require/include (or C's #include) where it just copy/pastes the source of the other module into your source -- in lua each module has its own scope [15:18:53] so the functions of the original module are going to be bound to the vars/functions of the original module -- your painting module can't override those [15:19:09] makes sense [15:19:51] now if you made conf and the like available on p, you can require the original as p (now that I see what you're trying to do, binding it to p is fine), then do p.conf = ..., etc. and then return p [15:19:59] and I *think* that should work [15:20:06] yeah... I dunno why the original does it like that [15:20:16] I dunno how much I actually care about this (helping someone scratch an itch at a hackathon) [15:20:43] Obviously, want to be careful of editing the original, because of it's high usage [15:21:20] * Reedy reverts painting for now [15:21:38] Need to play around with the sandbox one, and then use that in this [15:21:56] I don't know enough about lua to see how to hack around that and modify locals of the other module's scope (if it's even possible) [16:21:59] Skizzerz: looks like you were right :) [16:22:09] https://en.wikipedia.org/w/index.php?title=Module%3AAuthority_control%2Fsandbox&type=revision&diff=840704642&oldid=836348033 [16:22:22] Plus current contents of https://en.wikipedia.org/wiki/Module:Authority_control_painting/sandbox [16:23:25] * Reedy scopes the rest of the functions [16:24:05] * anomie sees scrollback but doesn't see anything that hasn't already been answered [16:24:45] anomie see https://bugs.chromium.org/p/gerrit/issues/detail?id=8812#c1 [16:25:14] Seems there priority now is removing gwtui [16:32:48] https://en.wikipedia.org/wiki/Module:Authority_control_painting [16:33:02] Now, do I dare modify https://en.wikipedia.org/wiki/Module:Authority_control/sandbox ? :D [16:34:10] uh, non sandbox