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' --[thecow275]--
local uuid = 'b08b6a7a-aada-4787-bb4b-07fc393ad6e5' --[QueenOfAsh]--
-- local villagedata = mw.ext.externalData.getExternalData({
-- url = "api.retromc.org/api/v1/village/getVillageList",
-- format = 'json',
-- data = url
-- })
local playerVillages = mw.ext.externalData.getExternalData({
url = "https://statistics.retromc.org/api/user_villages?uuid=" .. uuid,
format = 'json',
data = url
})
local retval = capiunto.create({
top = 'TESTING',
bodyClass = 'icr-DiamondCitizenBodyStyle',
topClass = 'icr-title'
})
retval:addRow('HOWDY', 'HOWDEE', '', 'icr-transparency1 icr-data')
local villagels = {}
if playerVillages.__json.data then
--table.insert(villagels, "1st layer works")
function villagehelper(PV_Input, PV_Name)
local PV_Input = PV_Input
local PV_Name = PV_Name
retval:addHeader(PV_Name)
mw.log(' DATA FOR: '..PV_Name..':')
for i, PV_Data in ipairs(PV_Input) do --[[ For Example: playerVillages.__json.data.member ]]--
--mw.log('villagehelper iterations: '..i)
--mw.logObject(PV_Data)
if type(PV_Data) == "table" and PV_Data.village then
mw.logObject(PV_Data.village)
mw.log('SUCCESS: PV_Data is a Table')
local PV_Data_Local = PV_Data.village
retval:addRow('',PV_Data_Local,'','icr-transparency1 icr-data')
elseif type(PV_Data) == "string" or PV_Data == nil then
mw.logObject(PV_Data)
mw.log('ERROR: PV_Data is a String or nil, Supposed to be a Table')
end
end
end
villagehelper(playerVillages.__json.data.member, "Member")
villagehelper(playerVillages.__json.data.owner, "Owner")
villagehelper(playerVillages.__json.data.assistant, "Assistant")
end
--mw.logObject(villagels)
--mw.logObject(playerVillages.__json.data.member)
--mw.logObject(member.village)
--mw.logObject(playerVillages.data)
--mw.logObject(playerVillages.status)
return retval
end
return p