Module:VillageTest: Difference between revisions

From RetroMC
Jump to navigation Jump to search
No edit summary
No edit summary
Line 41: Line 41:
     local playerVillages = mw.ext.externalData.getExternalData({
     local playerVillages = mw.ext.externalData.getExternalData({
         url = "https://statistics.retromc.org/api/user_villages?uuid=" .. uuid,
         url = "https://statistics.retromc.org/api/user_villages?uuid=" .. uuid,
         data = 'data',
          
        format = 'json'


     })
     })
Line 58: Line 57:


      
      
         for role in pairs({"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 _, member in ipairs({playerVillages.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 ?
             if playerVillages.data[role] then
             if playerVillages.data.member then
                 for village in pairs(playerVillages.data[role]) do
                 for member in pairs(playerVillages.data.member) do
                 table.insert(villagels, village.village)
                 table.insert(villagels, member.village)
                 retval:addRow('HOWDY', village.village, '', 'icr-transparency1 icr-data')
                 retval:addRow('HOWDY', member.village, '', 'icr-transparency1 icr-data')
              
              
                 end
                 end

Revision as of 18:27, 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,
        

    })
    
    local retval = capiunto.create({
        top = 'TESTING',
        bodyClass = 'icr-DiamondCitizenBodyStyle',
        topClass = 'icr-title'
    })

    retval:addRow('HOWDY', 'HOWDEE', '', 'icr-transparency1 icr-data')

    local villagels = {}
    if playerVillages.data then

    
        for _, member in ipairs({playerVillages.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 ?
            if playerVillages.data.member then
                for member in pairs(playerVillages.data.member) do
                table.insert(villagels, member.village)
                retval:addRow('HOWDY', member.village, '', 'icr-transparency1 icr-data')
            
                end
            
            end
        
        end
        return villagels
    end
    return retval
end
return p