Module:Sandbox/User:Simanelix/Module:SpriteLink
local p = {}
function p.main(frame) local args = frame:getParent().args local frameArgs = frame.args return p._main(args, frameArgs) end
function p._main(args, frameArgs) local edition = args.edition or frameArgs.edition -- "java" or "bedrock" local displayName = args.displayname local spriteType = args.spritetype -- "block", "entity", "biome", or "env" local nameId = args.nameid local aliasId = args.aliasid local numericId = args.id local itemForm = args.itemform or args.itemform2 -- "Identical" if block and entity share the same nameid local form = args.form -- "block" or "item" id only. unset for both. for bedrock: "block" = no /give command local fluidTags = args.fluidtags local blockTags = args.blocktags local itemTags = args.itemtags local entityTags = args.entityTags local translationKey = args.translationkey local translationType = args.translationtype or spriteType
if form == nil then form = {'block', 'item'} end
local ret = mw.html.create() local smw_sub = {}
local subname = (spriteType or 'ID') .. '_' .. nameId local smw_json = { ['Edition'] = edition, ['Display name'] = displayName, ['Type'] = spriteType, ['Resource location'] = nameId, ['Alias ID'] = aliasId, ['Numeric ID'] = numericId, ['Item Form'] = itemForm, ['Form'] = form, ['Fluid tags'] = fluidTags, ['Block tags'] = blockTags, ['Item tags'] = itemTags, ['Entity tags'] = entityTags, ['Translation key'] = translationKey, ['Translation type'] = translationType
}
mw.logObject(smw_json)
local smw_sub = { ['Edition'] = edition, ['Display name'] = displayName, ['Resource location'] = nameId, ['Resource location JSON'] = mw.text.jsonEncode(smw_json) } mw.logObject(smw_sub, subname)
local output = mw.smw.subobject(smw_sub, subname) if output ~= true then mw.logObject(output) end
ret = ret:allDone() return tostring(ret) end
return p