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

setPropertyはこの場所にも置くべきだったのか?
編集の要約なし
(setPropertyはこの場所にも置くべきだったのか?)
タグ: 手動差し戻し
 
(同じ利用者による、間の7版が非表示)
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 = ''
91行目: 121行目:
   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 = {}
   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+)回")
       -- 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+)回")
         num = mw.ustring.match(line, "(%d+)回")
       end
       end
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,187

回編集