「モジュール:SMWメンバー情報」の版間の差分

setPropertyはこの場所にも置くべきだったのか?
(ページの作成:「local p = {} local function setProperty(dataStore) -- メイン空間のみ if not mw.title.getCurrentTitle().namespace == 0 then return true; end if not mw.smw then return true; end local result = mw.smw.set( dataStore ) if result == true then -- everything ok else -- error message to be found in result.error end end local function test(frame) local args = frame.args --local args = require( 'Module:Argum…」)
 
(setPropertyはこの場所にも置くべきだったのか?)
タグ: 手動差し戻し
 
(2人の利用者による、間の9版が非表示)
26行目: 26行目:
   local dataStore = {}
   local dataStore = {}
   dataStore["主チーム"] = args["チーム"] or ""
   dataStore["主チーム"] = args["チーム"] or ""
   dataStore["主な元グループ"] = args["チーム"] or ""
   dataStore["主な元グループ"] = args["元グループ"] or ""
  dataStore["主チーム"] = args["チーム"] or ""
   dataStore["出身地"] = args["出身地"] or ""
   dataStore["出身地"] = args["出身地"] or ""
   dataStore["生年月日"] = args["生年月日"] or ""
   dataStore["生年月日"] = args["生年月日"] or ""
62行目: 61行目:
   dataStore["選抜回数"] = {}
   dataStore["選抜回数"] = {}


   local lines = mw.text.split(args["選抜回数"]or "", '<br>')
   local lines_s = mw.text.split(args["選抜回数"] or "", '<br>')
   mw.logObject(lines)
   mw.logObject(lines_s)
   local total = 0
   local total_s = 0
   -- Iterate over the lines
   -- Iterate over the lines_s
   for _, line in ipairs(lines) do
   for _, line in ipairs(lines_s) do
       local extractedGroup, num = mw.ustring.match(line, "(.+) (%d+)回")
       local extractedGroup, num = mw.ustring.match(line, "(.+) (%d+)回")
       mw.logObject(mw.ustring.match(line, "(.+) (%d+)回"))
       mw.logObject(mw.ustring.match(line, "(.+) (%d+)回"))
       -- If the group is not extracted, use the provided group
       -- If the group is not extracted, use the provided group
       if not extractedGroup or extractedGroup == "" then
       if not extractedGroup or extractedGroup == "" then
         extractedGroup = args["グループ"] or ""
         extractedGroup = args["元グループ"] or args["グループ"] or ""
       end
       end
       -- If the num is nil, return an error
       -- If the num is nil, return an error
78行目: 77行目:
       end
       end
       -- Store the group and selection times
       -- Store the group and selection times
       total = total + tonumber(num)
       if tonumber(num) > 0 then
      table.insert(dataStore["選抜回数"], extractedGroup .. ';' .. num)
        total_s = total_s + tonumber(num)
        table.insert(dataStore["選抜回数"], extractedGroup .. ';' .. num)
      end
  end
  -- Add the total selection times to the dataStore
  dataStore["選抜回数合計"] = total_s
 
  -- センター回数
  dataStore["選抜回数"] = {}
 
  local lines_c = mw.text.split(args["センター回数"] or "", '<br>')
  mw.logObject(lines_c)
  local total_c = 0
  -- Iterate over the lines_c
  for _, line in ipairs(lines_c) do
      local extractedGroup, num = mw.ustring.match(line, "(.+) (%d+)回")
      mw.logObject(mw.ustring.match(line, "(.+) (%d+)回"))
      -- If the group is not extracted, use the provided group
      if not extractedGroup or extractedGroup == "" then
        extractedGroup = args["元グループ"] or args["グループ"] or ""
      end
      -- If the num is nil, return an error
      if not num then
        return nil, "Unable to extract number from line: " .. line
      end
      -- Store the group and selection times
      if  tonumber(num) > 0 then
        total_c = total_c + tonumber(num)
        table.insert(dataStore["センター回数"], extractedGroup .. ';' .. num)
      end
   end
   end
   -- Add the total selection times to the dataStore
   -- Add the total selection times to the dataStore
   dataStore["選抜回数合計"] = total
   if total_c > 0 then
    dataStore["センター回数合計"] = total_c
  end


   local generation = ''
   local generation = ''
90行目: 120行目:
function p.main(frame)
function p.main(frame)
   local args = require( 'Module:Arguments' ).getArgs( frame, { wrappers = 'Template:メンバー情報', removeBlanks = false, parentFirst = true });
   local args = require( 'Module:Arguments' ).getArgs( frame, { wrappers = 'Template:メンバー情報', removeBlanks = false, parentFirst = true });
  local dataStore = {}


   -- 選抜回数
   -- 選抜回数
   dataStore["選抜回数"] = {}
   dataStore["選抜回数"] = {}


   local lines = mw.text.split(args["選抜回数"]or "", '<br>')
   local lines_s = mw.text.split(args["選抜回数"] or "", '<br>')
   mw.logObject(lines)
   mw.logObject(lines_s)
   local total = 0
   local total_s = 0
   -- Iterate over the lines
  -- Iterate over the lines_s
   for _, line in ipairs(lines) do
  for _, line in ipairs(lines_s) do
      local extractedGroup, num = mw.ustring.match(line, "(.+) (%d+)回")
      -- If the group is not extracted, use the provided group
      if not extractedGroup or extractedGroup == "" then
        extractedGroup = args["元グループ"] or args["グループ"] or ""
        num = mw.ustring.match(line, "(%d+)回")
      end
      -- If the num is nil, return an error
      if not num then
        return nil, "Unable to extract number from line: " .. line
      end
      -- Store the group and selection times
      if tonumber(num) > 0 then
        total_s = total_s + tonumber(num)
        table.insert(dataStore["選抜回数"], extractedGroup .. ';' .. num)
      end
  end
  -- Add the total selection times to the dataStore
  dataStore["選抜回数合計"] = total_s
  setProperty(dataStore);
 
  -- センター回数
  dataStore["センター回数"] = {}
 
  local lines_c = mw.text.split(args["センター回数"] or "", '<br>')
  mw.logObject(lines_c)
  local total_c = 0
   -- Iterate over the lines_c
   for _, line in ipairs(lines_c) do
       local extractedGroup, num = mw.ustring.match(line, "(.+) (%d+)回")
       local extractedGroup, num = mw.ustring.match(line, "(.+) (%d+)回")
      mw.logObject(mw.ustring.match(line, "(.+) (%d+)回"))
       -- If the group is not extracted, use the provided group
       -- If the group is not extracted, use the provided group
       if not extractedGroup or extractedGroup == "" then
       if not extractedGroup or extractedGroup == "" then
         extractedGroup = args["グループ"] or ""
         extractedGroup = args["元グループ"] or args["グループ"] or ""
        num = mw.ustring.match(line, "(%d+)回")
       end
       end
       -- If the num is nil, return an error
       -- If the num is nil, return an error
110行目: 169行目:
       end
       end
       -- Store the group and selection times
       -- Store the group and selection times
       total = total + tonumber(num)
       if tonumber(num) > 0 then
      table.insert(dataStore["選抜回数"], extractedGroup .. ';' .. num)
        total_c = total_c + tonumber(num)
        table.insert(dataStore["センター回数"], extractedGroup .. ';' .. num)
      end
   end
   end
   -- Add the total selection times to the dataStore
   -- Add the total selection times to the dataStore
   dataStore["選抜回数合計"] = total
 
   if total_c > 0 then
    dataStore["センター回数合計"] = total_c
  end
 
   setProperty(dataStore);
   setProperty(dataStore);
   return nil;
   return nil;
end
end


return p
return p
管理者、user-upload
32,114

回編集