Module:VillageTest: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 60: | Line 60: | ||
retval:addHeader('Member') | |||
for i, member in ipairs(playerVillages.__json.data.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 ? | for i, member in ipairs(playerVillages.__json.data.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 ? | ||
mw.log('iterations: '..i) | mw.log('iterations: '..i) | ||
| Line 70: | Line 70: | ||
mw.log('table WTF?') | mw.log('table WTF?') | ||
local localmember = member.village | local localmember = member.village | ||
retval:addRow('',localmember,'','icr-transparency1 icr-data') | retval:addRow('',localmember,'','icr-transparency1 icr-data') | ||
elseif type(member) == "string" then | elseif type(member) == "string" then | ||
| Line 84: | Line 84: | ||
-- end | -- end | ||
--end | --end | ||
end | |||
retval:addHeader('Owner') | |||
for i, owner in ipairs(playerVillages.__json.data.owner) 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 ? | |||
mw.log('iterations: '..i) | |||
mw.logObject(owner) | |||
if type(owner) == "table" and owner.village then | |||
mw.logObject(owner.village) | |||
mw.log('table WTF?') | |||
local localowner = owner.village | |||
retval:addRow('',localowner,'','icr-transparency1 icr-data') | |||
elseif type(owner) == "string" then | |||
mw.logObject(owner) | |||
mw.log('do be string') | |||
end | |||
end | |||
retval:addHeader('Assistant') | |||
for i, assistant in ipairs(playerVillages.__json.data.assistant) do --maybe this needs to be for pairs in data and then again for ipairs in assistant, member and assistant ? so maybe I need to create 2 tables for this and then handle it through that ? | |||
mw.log('iterations: '..i) | |||
mw.logObject(assistant) | |||
if type(assistant) == "table" and assistant.village then | |||
mw.logObject(assistant.village) | |||
mw.log('table WTF?') | |||
local localassistant = assistant.village | |||
retval:addRow('',localassistant,'','icr-transparency1 icr-data') | |||
elseif type(assistant) == "string" then | |||
mw.logObject(assistant) | |||
mw.log('do be string') | |||
end | |||
end | |||
Revision as of 21:39, 17 January 2025
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,
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")
retval:addHeader('Member')
for i, member in ipairs(playerVillages.__json.data.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 ?
mw.log('iterations: '..i)
mw.logObject(member)
--local member2 = member
if type(member) == "table" and member.village then
mw.logObject(member.village)
mw.log('table WTF?')
local localmember = member.village
retval:addRow('',localmember,'','icr-transparency1 icr-data')
elseif type(member) == "string" then
mw.logObject(member)
mw.log('do be string')
end
--for k, village in pairs(member2) do
-- if village then
-- retval:addRow('',village,'','icr-transparency1 icr-data')
-- mw.log('VillageStuff? : '..k)
-- mw.logObject(village)
-- end
--end
end
retval:addHeader('Owner')
for i, owner in ipairs(playerVillages.__json.data.owner) 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 ?
mw.log('iterations: '..i)
mw.logObject(owner)
if type(owner) == "table" and owner.village then
mw.logObject(owner.village)
mw.log('table WTF?')
local localowner = owner.village
retval:addRow('',localowner,'','icr-transparency1 icr-data')
elseif type(owner) == "string" then
mw.logObject(owner)
mw.log('do be string')
end
end
retval:addHeader('Assistant')
for i, assistant in ipairs(playerVillages.__json.data.assistant) do --maybe this needs to be for pairs in data and then again for ipairs in assistant, member and assistant ? so maybe I need to create 2 tables for this and then handle it through that ?
mw.log('iterations: '..i)
mw.logObject(assistant)
if type(assistant) == "table" and assistant.village then
mw.logObject(assistant.village)
mw.log('table WTF?')
local localassistant = assistant.village
retval:addRow('',localassistant,'','icr-transparency1 icr-data')
elseif type(assistant) == "string" then
mw.logObject(assistant)
mw.log('do be string')
end
end
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