Editing Module:Get drop info 0 You do not have permission to edit this page, for the following reasons: The action you have requested is limited to users in one of the groups: Autoconfirmed users, FANDOM Staff, FANDOM Helpers, Wiki Managers, Content Team Members. {|class="messagebox info" |width="50px"| |Please log in to edit the wiki. Joining is free and it only takes a minute.We hope that you sign up and become a member of our community! |} You must confirm your e-mail address before editing pages. Please set and validate your e-mail address through your user preferences. more + You can view and copy the source of this page: -- <pre> local p = {} local JSONS = require('Module:Json') function p.main(frame) -- This template is fairly expensive to use, so it should be limited mw.incrementExpensiveFunctionCount() local args = frame:getParent().args local monster = string.gsub(args['?monster'] or args.monster or '','[][]','') monster = mw.text.decode(monster) local drop = string.lower(args.userparam or args.drop or '') drop = mw.text.decode(drop) -- escape lua characters local _drop = drop:gsub('([%^%$%(%)%%%.%[%]%*%+%-%?])','%%%1') local smwdata = frame:preprocess('{{'.. '{{{|safesubst:}}}#show:'.. monster.. [[ |?Drop JSON |?All Combat level=&&SPLITPOINT&&Combat level: |headers=plain |format=list }} ]]) smwdata = mw.text.decode(tostring(smwdata)) local _found = false local json, cmb = unpack( mw.text.split(smwdata,'%(&&SPLITPOINT&&') ) local json_good json_good, json = pcall(JSONS.decode,string.format('[ %s ]',json)) if not json_good then return '' end cmb = string.format( '(%s',cmb or '?' ) local ret = {} for _, v in pairs(json) do if drop == string.lower(v.name) then table.insert(ret,v) _found = true end end if not _found then return '' end local combat = mw.ustring.match(cmb:lower(),'%(combat level: (.-)%)') or 'N/A' combat = mw.ustring.gsub(combat,'(%d),(%d%d%d)','%1%2') local retString = {} for _, v in pairs(ret) do local _min,_max = v.quantity[1],v.quantity[2] local quantity if tonumber(_min) == tonumber(_max) then quantity = _min else quantity = string.format('%s-%s',_min,_max) end table.insert(retString, string.format('{{ItemDropsLine|Monster=%s|Combat=%s|Quantity=%s|Rarity=%s}}', monster, combat, quantity, v.rarity) ) end return frame:preprocess(table.concat(retString,'\n')) end return p Return to Module:Get drop info. Edit summary Show changes