Technik Wiki
Advertisement
Technik Wiki

Die Dokumentation für dieses Modul kann unter Modul:Datei/Formatierung/Dokumentation erstellt werden

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/Alle-Standard-Vorlagen#%1|#minecraft:%1]]' )
		text = text:gsub( 'function ([%l%d%-_]+:[%l%d%.%-_/]+)', 'function [[#%1|%1]]' )
		text = text:gsub( 'schedule clear ([%l%d%-_]+:[%l%d%.%-_/]+)', 'schedule clear [[#%1|%1]]' )
		text = text:gsub( 'advancement (%l+ .+ %l+) minecraft:recipes/([%l_]+)/([%l_]+)', 'advancement %1 [[:mcw:%3|minecraft:recipes/%2/%3]]' )
		text = text:gsub( 'advancement (%l+ .+ %l+) (minecraft:[%l_/]+)', 'advancement %1 [[:mcw:Fortschritte#%2|%2]]' )
		text = text:gsub( 'advancement (%l+ .+) only ([%l%d%-_]+:[%l%d%.%-_/]+) (.+)', 'advancement %1 only [[#%2|%2]] [[#%2-criteria|%3]]' )
		text = text:gsub( 'advancement (%l+ .+ %l+) ([%l%d%-_]+:[%l%d%.%-_/]+)', 'advancement %1 [[#%2|%2]]' )
		text = text:gsub( 'advancements=(%{[^%}]+%})', function(fortschritte)
			fortschritte = fortschritte:gsub( '([%{,]%s*)minecraft:recipes/([%l_]+)/([%l_]+)=', '%1[[:mcw:%3|minecraft:recipes/%2/%3]]=' )
			fortschritte = fortschritte:gsub( '([%{,]%s*)(minecraft:[%l_/]+)=', '%1[[:mcw:Fortschritte#%2|%2]]=' )
			fortschritte = fortschritte:gsub( '([%{,]%s*)([%l%d%-_]+:[%l%d%.%-_/]+)=', '%1[[#%2|%2]]=' )
			return 'advancements=' .. fortschritte
		end )
		text = text:gsub( 'recipe (%l+ .+) minecraft:([%l_/]+)', 'recipe %1 [[:mcw:%2|minecraft:%2]]' )
		text = text:gsub( 'recipe (%l+ .+) ([%l%d%-_]+:[%l%d%.%-_/]+)', 'recipe %1 [[#%2|%2]]' )
		text = text:gsub( 'loot (.+) loot minecraft:([%l_/]+)', 'loot %1 loot [[:mcw:Beutetabellen/Alle-Standard-Vorlagen#%2|minecraft:%2]]' )
		text = text:gsub( 'loot (.+) loot ([%l%d%-_]+:[%l%d%.%-_/]+)', 'loot %1 loot [[#%2|%2]]' )
		text = text:gsub( 'loot (.+) fish minecraft:([%l_/]+)', 'loot %1 fish [[:mcw:Beutetabellen/Alle-Standard-Vorlagen#%2|minecraft:%2]]' )
		text = text:gsub( 'loot (.+) fish ([%l%d%-_]+:[%l%d%.%-_/]+)', 'loot %1 fish [[#%2|%2]]' )
		text = text:gsub( 'predicate ([%l%d%-_]+:[%l%d%.%-_/]+)', 'predicate [[#%1|%1]]' )
		text = text:gsub( 'predicate=(!?)([%l%d%-_]+:[%l%d%.%-_/]+)', 'predicate=%1[[#%2|%2]]' )
		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( '([%{,]%s*LootTable:%s*\\*)(["\'])minecraft:([%l_/]+)%2', '%1%2[[:mcw:Beutetabellen/Alle-Standard-Vorlagen#%3|minecraft:%3]]%2' )
		text = text:gsub( '([%{,]%s*LootTable:%s*\\*)(["\'])([%l%d%-_]+:[%l%d%.%-_/]+)%2', '%1%2[[#%3|%3]]%2' )
		text = text:gsub( '([%{,]%s*DeathLootTable:%s*\\*)(["\'])minecraft:([%l_/]+)%2', '%1%2[[:mcw:Beutetabellen/Alle-Standard-Vorlagen#%3|minecraft:%3]]%2' )
		text = text:gsub( '([%{,]%s*DeathLootTable:%s*\\*)(["\'])([%l%d%-_]+:[%l%d%.%-_/]+)%2', '%1%2[[#%3|%3]]%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 string.find( text, '^%s*"__comment":' ) then
		text = '<span style="color:grey">' .. text .. '</span>'
	elseif 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/Alle-Standard-Vorlagen#%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/Alle-Standard-Vorlagen#%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/Alle-Standard-Vorlagen#%2|minecraft:%2]]"' )
		text = text:gsub( '("tag":%s*)"([%l%d%-_]+:[%l%d%.%-_/]+)"', '%1"[[#%2|%2]]"' )
	elseif type == 'predicate' then
		text = text:gsub( '("item":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:%2|minecraft:%2]]"' )
		text = text:gsub( '("tag":%s*)"minecraft:([%l_]+)"', '%1"[[:mcw:Aliasdaten/Alle-Standard-Vorlagen#%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
Advertisement