(Änderung 50234 von MarkusRost (Diskussion) rückgängig gemacht.) Markierung: Rückgängigmachung |
KKeine Bearbeitungszusammenfassung |
||
Zeile 6: | Zeile 6: | ||
text = '<span style="color:grey">' .. text .. '</span>' |
text = '<span style="color:grey">' .. text .. '</span>' |
||
else |
else |
||
− | text = text:gsub( '#([%l%d |
+ | text = text:gsub( '#([%l%d%-_]+:[%l%d%.%-_/]+)', '[[#%1]]' ) |
text = text:gsub( '%[%[#minecraft:([%l_]+)%]%]', '[[:mcw:Aliasdaten#%1|#minecraft:%1]]' ) |
text = text:gsub( '%[%[#minecraft:([%l_]+)%]%]', '[[:mcw:Aliasdaten#%1|#minecraft:%1]]' ) |
||
− | text = text:gsub( 'function ([%l%d |
+ | text = text:gsub( 'function ([%l%d%-_]+:[%l%d%.%-_/]+)', 'function [[#%1|%1]]' ) |
text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) (from|only|through|until) minecraft:recipes/([%l_]+)/([%l_]+)', '%1advancement %2 %3 %4 [[:mcw:%6|minecraft:recipes/%5/%6]]' ) |
text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) (from|only|through|until) minecraft:recipes/([%l_]+)/([%l_]+)', '%1advancement %2 %3 %4 [[:mcw:%6|minecraft:recipes/%5/%6]]' ) |
||
text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) (from|only|through|until) (minecraft:[%l_]+)', '%1advancement %2 %3 %4 [[:mcw:Fortschritte#%5|%5]]' ) |
text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) (from|only|through|until) (minecraft:[%l_]+)', '%1advancement %2 %3 %4 [[:mcw:Fortschritte#%5|%5]]' ) |
||
− | text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) only ([%l%d |
+ | text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) only ([%l%d%-_]+:[%l%d%.%-_/]+) (.+)', '%1advancement %2 %3 only [[#%4|%4]] [[#%4-criteria|%5]]' ) |
− | text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) (from|only|through|until) ([%l%d |
+ | text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) (from|only|through|until) ([%l%d%-_]+:[%l%d%.%-_/]+)', '%1advancement %2 %3 %4 [[#%5|%5]]' ) |
text = text:gsub( '(^/?|run )recipe (give|take) (.+) minecraft:([%l_]+)', '%1recipe %2 %3 [[:mcw:%4|minecraft:%4]]' ) |
text = text:gsub( '(^/?|run )recipe (give|take) (.+) minecraft:([%l_]+)', '%1recipe %2 %3 [[:mcw:%4|minecraft:%4]]' ) |
||
− | text = text:gsub( '(^/?|run )recipe (give|take) (.+) ([%l%d |
+ | text = text:gsub( '(^/?|run )recipe (give|take) (.+) ([%l%d%-_]+:[%l%d%.%-_/]+)', '%1recipe %2 %3 [[#%4|%4]]' ) |
text = text:gsub( '^/?(%l+)', '[[:mcw:Befehl/%1|%1]][[Kategorie:Seiten mit %1]]' ) |
text = text:gsub( '^/?(%l+)', '[[:mcw:Befehl/%1|%1]][[Kategorie:Seiten mit %1]]' ) |
||
text = text:gsub( 'run (%l+)', 'run [[:mcw:Befehl/%1|%1]][[Kategorie:Seiten mit %1]]' ) |
text = text:gsub( 'run (%l+)', 'run [[:mcw:Befehl/%1|%1]][[Kategorie:Seiten mit %1]]' ) |
||
Zeile 28: | Zeile 28: | ||
type = type or '' |
type = type or '' |
||
if type == 'advancement' then |
if type == 'advancement' then |
||
− | text = text:gsub( '("function":%s*)"([%l%d |
+ | text = text:gsub( '("function":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' ) |
text = text:gsub( '("item":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' ) |
text = text:gsub( '("item":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' ) |
||
− | text = text:gsub( '("loot":%s*)"([%l%d |
+ | text = text:gsub( '("loot":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' ) |
text = text:gsub( '("loot":%s*)"%[%[#(minecraft:[%l_/]+)%|%2%]%]"', '%1"%2"' ) |
text = text:gsub( '("loot":%s*)"%[%[#(minecraft:[%l_/]+)%|%2%]%]"', '%1"%2"' ) |
||
text = text:gsub( '("parent":%s*)"minecraft:recipes/([%l_]+)/([%l_]+)"', '%1"[[:mcw:%3|minecraft:recipes/%2/%3]]"' ) |
text = text:gsub( '("parent":%s*)"minecraft:recipes/([%l_]+)/([%l_]+)"', '%1"[[:mcw:%3|minecraft:recipes/%2/%3]]"' ) |
||
text = text:gsub( '("parent":%s*)"(minecraft:[%l_]+)"', '%1"[[:mcw:Fortschritte#%2|%2]]"' ) |
text = text:gsub( '("parent":%s*)"(minecraft:[%l_]+)"', '%1"[[:mcw:Fortschritte#%2|%2]]"' ) |
||
− | text = text:gsub( '("parent":%s*)"([%l%d |
+ | text = text:gsub( '("parent":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' ) |
text = text:gsub( '("recipes":%s*)"minecraft:([%l_/]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' ) |
text = text:gsub( '("recipes":%s*)"minecraft:([%l_/]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' ) |
||
− | text = text:gsub( '("recipes":%s*)"([%l%d |
+ | text = text:gsub( '("recipes":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' ) |
text = text:gsub( '("tag":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:Aliasdaten#%2|minecraft:%2]]"' ) |
text = text:gsub( '("tag":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:Aliasdaten#%2|minecraft:%2]]"' ) |
||
− | text = text:gsub( '("tag":%s*)"([%l%d |
+ | text = text:gsub( '("tag":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' ) |
text = text:gsub( '("trigger":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:Fortschrittsdaten#%2|minecraft:%2]]"' ) |
text = text:gsub( '("trigger":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:Fortschrittsdaten#%2|minecraft:%2]]"' ) |
||
elseif type == 'alias' then |
elseif type == 'alias' then |
||
text = text:gsub( '"minecraft:([%l_]+)"', '"[[:mcw:%1|minecraft:%1]]"' ) |
text = text:gsub( '"minecraft:([%l_]+)"', '"[[:mcw:%1|minecraft:%1]]"' ) |
||
text = text:gsub( '"#minecraft:([%l_]+)"', '"[[:mcw:Aliasdaten#%1|#minecraft:%1]]"' ) |
text = text:gsub( '"#minecraft:([%l_]+)"', '"[[:mcw:Aliasdaten#%1|#minecraft:%1]]"' ) |
||
− | text = text:gsub( '"#([%l%d |
+ | text = text:gsub( '"#([%l%d%-_]+:[%l%d%.%-_/]+)"', '"[[#%1]]"' ) |
elseif type == 'loot' then |
elseif type == 'loot' then |
||
text = text:gsub( '("name":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' ) |
text = text:gsub( '("name":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' ) |
||
− | text = text:gsub( '("name":%s*)"([%l%d |
+ | text = text:gsub( '("name":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' ) |
text = text:gsub( '("name":%s*)"%[%[#(minecraft:[%l%d%.%-_/]+)%|%2%]%]"', '%1"%2"' ) |
text = text:gsub( '("name":%s*)"%[%[#(minecraft:[%l%d%.%-_/]+)%|%2%]%]"', '%1"%2"' ) |
||
elseif type == 'recipe' then |
elseif type == 'recipe' then |
||
text = text:gsub( '("item":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' ) |
text = text:gsub( '("item":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' ) |
||
text = text:gsub( '("tag":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:Aliasdaten#%2|minecraft:%2]]"' ) |
text = text:gsub( '("tag":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:Aliasdaten#%2|minecraft:%2]]"' ) |
||
− | text = text:gsub( '("tag":%s*)"([%l%d |
+ | text = text:gsub( '("tag":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' ) |
end |
end |
||
return text |
return text |
Version vom 17. März 2020, 19:38 Uhr
Das Modul Datei/Formatierung stellt die Funktionen befehlsblock, befehl und json zur Verfügung. Dies ermöglicht die Formatierung der Befehle und JSON-Texte innerhalb von Befehlsblöcken oder Dateien.
Aufruf
Die Parameter des Aufrufers werden automatisch übergeben. Das sind:
für {{#invoke:Datei/Formatierung|befehlsblock}}
siehe Vorlage:Befehlsblock
für {{#invoke:Datei/Formatierung|befehl}}
siehe Vorlage:Funktion
für {{#invoke:Datei/Formatierung|json}}
siehe Vorlage:JSON-Datei
Zur Liste aller Vorlagen und Module |
local p = {}
function p.befehl(text)
text = text or ''
if string.find( text, '^%#' ) then
text = '<span style="color:grey">' .. text .. '</span>'
else
text = text:gsub( '#([%l%d%-_]+:[%l%d%.%-_/]+)', '[[#%1]]' )
text = text:gsub( '%[%[#minecraft:([%l_]+)%]%]', '[[:mcw:Aliasdaten#%1|#minecraft:%1]]' )
text = text:gsub( 'function ([%l%d%-_]+:[%l%d%.%-_/]+)', 'function [[#%1|%1]]' )
text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) (from|only|through|until) minecraft:recipes/([%l_]+)/([%l_]+)', '%1advancement %2 %3 %4 [[:mcw:%6|minecraft:recipes/%5/%6]]' )
text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) (from|only|through|until) (minecraft:[%l_]+)', '%1advancement %2 %3 %4 [[:mcw:Fortschritte#%5|%5]]' )
text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) only ([%l%d%-_]+:[%l%d%.%-_/]+) (.+)', '%1advancement %2 %3 only [[#%4|%4]] [[#%4-criteria|%5]]' )
text = text:gsub( '(^/?|run )advancement (grant|revoke) (.+) (from|only|through|until) ([%l%d%-_]+:[%l%d%.%-_/]+)', '%1advancement %2 %3 %4 [[#%5|%5]]' )
text = text:gsub( '(^/?|run )recipe (give|take) (.+) minecraft:([%l_]+)', '%1recipe %2 %3 [[:mcw:%4|minecraft:%4]]' )
text = text:gsub( '(^/?|run )recipe (give|take) (.+) ([%l%d%-_]+:[%l%d%.%-_/]+)', '%1recipe %2 %3 [[#%4|%4]]' )
text = text:gsub( '^/?(%l+)', '[[:mcw:Befehl/%1|%1]][[Kategorie:Seiten mit %1]]' )
text = text:gsub( 'run (%l+)', 'run [[:mcw:Befehl/%1|%1]][[Kategorie:Seiten mit %1]]' )
text = text:gsub( '(\\*"value\\*":%s*\\*")/(%l+)', '%1[[:mcw:Befehl/%2|/%2]][[Kategorie:Seiten mit %2]]' )
text = text:gsub( '([%{,]%s*Command:%s*\\*")/?(%l+)', '%1[[:mcw:Befehl/%2|%2]][[Kategorie:Seiten mit %2]]' )
text = text:gsub( '(minecraft:structure_block)', '%1[[Kategorie:Konstruktionsblock]]' )
end
return text
end
function p.json(text, type)
text = text or ''
type = type or ''
if type == 'advancement' then
text = text:gsub( '("function":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' )
text = text:gsub( '("item":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' )
text = text:gsub( '("loot":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' )
text = text:gsub( '("loot":%s*)"%[%[#(minecraft:[%l_/]+)%|%2%]%]"', '%1"%2"' )
text = text:gsub( '("parent":%s*)"minecraft:recipes/([%l_]+)/([%l_]+)"', '%1"[[:mcw:%3|minecraft:recipes/%2/%3]]"' )
text = text:gsub( '("parent":%s*)"(minecraft:[%l_]+)"', '%1"[[:mcw:Fortschritte#%2|%2]]"' )
text = text:gsub( '("parent":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' )
text = text:gsub( '("recipes":%s*)"minecraft:([%l_/]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' )
text = text:gsub( '("recipes":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' )
text = text:gsub( '("tag":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:Aliasdaten#%2|minecraft:%2]]"' )
text = text:gsub( '("tag":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' )
text = text:gsub( '("trigger":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:Fortschrittsdaten#%2|minecraft:%2]]"' )
elseif type == 'alias' then
text = text:gsub( '"minecraft:([%l_]+)"', '"[[:mcw:%1|minecraft:%1]]"' )
text = text:gsub( '"#minecraft:([%l_]+)"', '"[[:mcw:Aliasdaten#%1|#minecraft:%1]]"' )
text = text:gsub( '"#([%l%d%-_]+:[%l%d%.%-_/]+)"', '"[[#%1]]"' )
elseif type == 'loot' then
text = text:gsub( '("name":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' )
text = text:gsub( '("name":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' )
text = text:gsub( '("name":%s*)"%[%[#(minecraft:[%l%d%.%-_/]+)%|%2%]%]"', '%1"%2"' )
elseif type == 'recipe' then
text = text:gsub( '("item":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' )
text = text:gsub( '("tag":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:Aliasdaten#%2|minecraft:%2]]"' )
text = text:gsub( '("tag":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' )
end
return text
end
function p.befehlsblock( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( 'Modul:ParameterUmwandeln' ).merge( true )
else
f = mw.getCurrentFrame()
end
return p.befehl( args.text )
end
return p