Module:VillageTest
Documentation for this module may be created at Module:VillageTest/doc
local p = {}
--local capiunto = require 'capiunto'
--[ Thecow275's WikiStats V2 VIllages MODULE PROTOTYPE ]
--[ Nicknamed: UUID and J-Village Update]
local function preprocessArg(s)
if not s then
return nil
end
s = s:match('^%s*(.-)%s*$') --trim whitespace
if s == '' then
return nil
else
return s
end
end
function p.main(frame)
local args = frame.args
--local input = preprocessArg(args[1])
-- local datatype = preprocessArg(args[2]) -- currently unused will be used whenever I implement more datatypes
-- local UUIDORUSER = preprocessArg(args[3]) -- Selector for if input is username OR UUID
-- local PlayerORVillage = preprocessArg(args[4]) -- Jesus christ argument just so you can specify if you are searching for village data YES village data
-- this module will get bloated with the jvillage stuff but EHHH
--if not input then -- CHECK FOR BLANK INPUT
-- return 'INPUT ERROR INPUT IS NULL'
--end
local uuid = '8fa8f70d-eb7d-4743-b0ad-837cdfb69f4e'
local villagedata = mw.ext.externalData.getExternalData({
url = "api.retromc.org/api/v1/village/getVillageList",
format = 'json'
})
local playerVillages = mw.ext.externalData.getExternalData({
url = "https://statistics.retromc.org/api/user_villages?uuid=" .. uuid,
data = {data='data',member='data:member',assistant='data:assistant'},
format = 'json'
})
local villagels = {}
if playerVillages then
for ownerData in playerVillages.member do --maybe this needs to be for pairs in data and then again for ipairs in owner, member and assistant ? so maybe I need to create 2 tables for this and then handle it through that ?
if ownerData.data.member then -- the data seems to be of Object - > Object -> Array -> Object. So I need to deal with that I guess
table.insert(villagels, ownerData.member.village)
end
return villagels
end
end
end
return p