Topic on Project:Support desk

Import templates and module from https://minecraft.gamepedia.com

19
Summary by Sqrkz

The reason is probably a difference in the mediawiki versions of my and minecraft's wiki

Sqrkz (talkcontribs)

Hi !

I would like to use some of the modules from the minecraft wiki such as this one :

https://minecraft.gamepedia.com/Module:Sprite

So I used the special:Export from this wiki and special:Import_pages on mine to get the module and the dependencies

https://www.wikifield.fr/wiki/Module:Sprite

However, when I try to use it, the items do not display

Works : https://minecraft.gamepedia.com/Template:Sprite

Does not work : https://www.wikifield.fr/wiki/Modèle:Sprite :'(

(I think the TNT error is unrelated)


Any idea of what I could have missed ?

Thanks !

AhmadF.Cheema (talkcontribs)

Your Wiki is using newer versions of MediaWiki and Extension:Scribunto as compared to Minecraft Wiki. It is probable that the module you are trying to import is incompatible with your version.

Sqrkz (talkcontribs)

Damn, that would make sense :(

Okay, thanks for your Help Ahmad, you probably don't remember but you also helped me a few month ago for another issue, you are doing remarkable work here :)

AhmadF.Cheema (talkcontribs)

The module that's giving errors appears to be your Module:TNT which is derived from MediaWiki's Module:TNT. In this particular case your Wiki is the one with the older versions.

By going through Module:TNT&action=history you can try copying an older iteration of the module into your Wiki and see if it resolves the errors. An iteration from the time mediawiki.org was running the version of Extension:Scribunto which you're running now.

Sqrkz (talkcontribs)

Yeah I noticed the errors from TNT but I assumed they were not related to my issue as this is a module about translation for documentation. Are you sure that might be the cause of my troubles ?

So anyway, I tried the Module:TNT iteration of 21st March 2019 (same date as my Scribunto version) as you suggested but the situation does not seem to be improved unfortunately... I tried other versions before and after this date, but I still get this error :

Erreur Lua à la ligne 141 : attempt to index field 'data' (a nil value).

Roughly translatable to Error Lua at line 141 : attempt to index field 'data' (a nil value). I haven't find any useful information on the web to debug it and I don't understand the modules enough to see where it comes from

Again thanks for you time and help !

Bawolff (talkcontribs)

It looks like the code from around line 141 is:

 local data = args.data and mw.loadData( 'Module:' .. args.data ) or {}
 local categories = {}
 local idData = args.iddata
 if not idData then
  local name = args.name or data.settings.name
  local id = mw.text.trim( tostring( args[1] or '' ) )
  idData = data.ids[id] or data.ids[mw.ustring.lower( id ):gsub( '[%s%+]', '-' )]
end

So your error is saying that data is nil, which means it you can't index (i.e. call [ids]). But the error doesn't seem right as data is a local not a field (ids is the field on line 141), and its impossible for data to be nil in this block since it falls back to {} if the data load is nil.

So I don't know. On the other hand, you seem to have a different error on Modèle:Sprite now, that seems to be related to showing documentation and not related to Module:Sprite

Sqrkz (talkcontribs)

Hi Bawolff thanks for taking a look to my issue :)

Yeah I wasn't able to understand the error too, and it seems using an old version of TNT wasn't very succesful... Ahmad previously mentionned that my Mediawiki and scribunto were ahead of minecraft wiki . So maybe using an old version of Scribunto would help ? However, I don't know which one to use because the version use on the wiki doesn't show on Special:Version :(

Any other idea ?

AhmadF.Cheema (talkcontribs)

The Extension:Scribunto version that is being used on a specific MediaWiki instance will usually correspond to that MediaWiki core version. Therefore, if Minecraft Wiki is using MediaWiki v1.31, the extension version will also be the one for version 1.31, as can be pointed out on the Special:ExtensionDistributor/Scribunto page.

Furthermore, you'll probably not be able to use older Scribunto version with your newer MediaWiki instance. In this case, both core and extension versions usually have to correspond to each other in order to run.

Sqrkz (talkcontribs)

Damn, I guess I should have stick to the LTS version of mediawiki :(

Now I can only hope minecraft wiki will update to 1.35 when it comes out

Bawolff (talkcontribs)

I don't think its a version mismatch. Well it is definitely true that scribunto usually corresponds to a specific core version, the type of your errors aren't really the type i would associate with a wrong version (i.e. They are all null dereference errors, none are related to library usage).

The module:TNT error is because Module:Documentation/config is calling the format method of Module:TNT, but the version of TNT you have does not have that method (e.g. p.format is nowhere to be found in it). So that is definitely not a version error in scribunto. I think you need to copy the latest version of Module:TNT from https://www.mediawiki.org/w/index.php?title=Module:TNT&action=edit [at least for that issue, other issues may be other things]

Sqrkz (talkcontribs)

Are you referring to 'Error Lua at line 157 : attempt to index field 'data' (a nil value)'

(that can be found here https://www.wikifield.fr/wiki/Module:TNT) ? Or this https://www.wikifield.fr/wiki/Modèle:Sprite ?

Because I already switche back to the current TNT (yesterday I think) version as you just suggested and that nil error is still here. Both my Module:Documentation/config and Module:TNT are up to date wih MediaWiki

Regarding this module here : https://www.wikifield.fr/wiki/Modèle:Sprite that i'm trying to import from mc wiki, I'm pretty sure documentation and TNT, though they are definitely faulty on my wiki, aren't the reason for which the module doesn't work. (Or what could make us think so ?) Is there any way I could see why my attempts to use it one https://www.wikifield.fr/wiki/Blocs_Minefield does not work. i mean, it does not even produce an error as far as I know =/

Again, thanks for your time to both of you, I really appreciate it !

Bawolff (talkcontribs)

It was a different error last time i looked.

For the "Error Lua at line 157 : attempt to index field 'data' (a nil value)'"

This seems to be caused by the line local data = mw.ext.data.get(dataset, lang)

mw.ext.data is a feature provided by extension:JsonConfig, which provides access to stuff in the Data namespace. AFAICT You don't have that extension, which is where that error is coming from.

I agree, that at first glance, TNT is not responsible for Sprite not working.

It seems like the sprite call expands to:

<span class="sprite" style="background-image:{{ #widget: FileUrl | url = {{ #sub: https://www.wikifield.fr/w/images/d/de/BlocCSS.png | {{ #len: {{ #explode: | b/bc/ }} }} }} }};background-position:-0px -0px;height:1px;width:1px"></span>

So it seems like there is a couple problems with that. First of all, background-image css property is usually banned in wikitext. So not sure how that worked at all at minecraft wiki. Maybe widgets overrides that somehow. Second its calling out to the widgets extension (Which is associated with the widgets namespace, aka Widget:FileUrl ), which you don't have installed. Last of all, they are using #len and #explode, which is part of the ParserFunctions extension. However its only enabled if $wgPFEnableStringFunctions = true; is set in LocalSettings.php, which it doesn't appear to be in your wiki.

Bawolff (talkcontribs)

Honestly, at some point here, you may want to consider if its less work to make your own sprite template, than to copy this insanely complex one.

Sqrkz (talkcontribs)

Thank you very much Bawolff for this very detailled report you hand to me here :)

I will consider your suggestion and develop my own modules and template, I have basic knowledge in programmation and scripting so it might be tricky though.

Again thanks for your help !

Sqrkz (talkcontribs)

So I followed your advices and I come back with some updates :

- Even though I installed JsonConfig, the error is still here. I will go through the configuration step tomorrow but until then if someone has an idea of what step could be missing, any help will be appreciated

- Regarding the sprite module, I also installed all the required extensions and I felt I was getting closer to make this thing work. Now, I feel the issue might come from the background-image field. See below, my wiki uses full path while minecraft wiki uses relative path. So, yes, if you copy paste my URL you will notice it works. However, maybe the module and templates where made only to work with relative path ? + I know showing full-path like this of my wiki is not good for security. How can I edit this ?

My wiki : https://i.imgur.com/5NBwS6v.png

MC wiki : https://i.imgur.com/HHduM0E.png

The module : https://www.wikifield.fr/wiki/Widget:FileUrl uses a $url variable that I have no idea how to edit.

Bawolff (talkcontribs)

For json config, you need some config for it to. At the very least, you need $wgJsonConfigEnableLuaSupport = true;. You probably also need to set $wgJsonConfigs up. I'm not very familar with json config, so i don't know precisely the right settings, but you can see what wikimedia does at least, at https://noc.wikimedia.org/conf/CommonSettings.php.txt (in the middle of the file) although that config probably doesn't entirely make sense for your wiki. See the documentaiton on extension:JsonConfig

Full path should be fine in a background-image, as long as the path is correct.

Bawolff (talkcontribs)

I think the last reason your sprite isn't working is because the following code:

/* [[Template:Sprite]] */
.sprite {
  display: inline-block;
  vertical-align: text-top;
  height: 16px;
  width: 16px;
  background-repeat: no-repeat;
}
.sprite + .sprite-text {
  padding-left: 0.312em;
}

from https://minecraft.gamepedia.com/MediaWiki:Gadget-site-styles.css

isn't in your wiki. I think you might want to add it to the page MediaWiki:Common.css on your wiki (Mediawiki:Common.css is auto included everywhere. I think minecraftwiki put it in a gadget so that people can disable it in their Special:Preferences)

In particular, the line display:inline-block is important because by default span tags are display:inline, which means you can't set the width with css, which was making your span invisible as it was 0px wide.

Sqrkz (talkcontribs)

Woooow getting closer thanks to your recommendation ! For some reasons, it seems a submodule of Sprite, InvSprite is now working as expected ! (doing approx. the same thing as Sprite but with some special options). However, for Sprite itself, it seems there is still one issue :

https://www.wikifield.fr/wiki/Blocs_Minefield

As you can see, it displays the whole SpriteSheet (you can also notice that, at the end of the page, InvSprite is working very well) Any idea for which Sprite is doing that ?

Again, a huuuuge thanks for your help.

Sqrkz (talkcontribs)

NVM !!! I was just using wrong parameters for Sprite !

So, except Module:TNT, for which I need more time to config JsonConfig, everything is working just fine. Thanks again for your help !

Reply to "Import templates and module from https://minecraft.gamepedia.com"