Ace Attorney Wiki
Edit Page
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 83: Line 83:
 
end
 
end
   
function p.tableRange(frame)
+
function partialTable(frame, firstRow, lastRow)
-- Constructs a subtable of the given table containing the specified range of rows.
 
-- {{#invoke:table|tableRange|(table)|3|7}} produces a table using rows 3-7 of the original table.
 
 
local wikitable = frame.args[1]
 
local wikitable = frame.args[1]
 
local rowP = rowPositions(wikitable)
 
local rowP = rowPositions(wikitable)
 
local length = rows(wikitable)
 
local length = rows(wikitable)
local firstRow = math.max(frame.args[2], 1) or 1
 
local lastRow = math.min(frame.args[3], length) or length
 
 
local header = string.sub(wikitable, 1, rowP[1] - 1)
 
local header = string.sub(wikitable, 1, rowP[1] - 1)
 
local body = fetchRows(wikitable, firstRow, lastRow)
 
local body = fetchRows(wikitable, firstRow, lastRow)
 
return header .. body .. "}"
 
return header .. body .. "}"
  +
end
  +
  +
function p.tableRange(frame)
 
-- Constructs a subtable of the given table containing the specified range of rows.
 
-- {{#invoke:table|tableRange|(table)|3|7}} produces a table using rows 3-7 of the original table.
 
local firstRow = math.max(frame.args[2], 1) or 1
 
local lastRow = math.min(frame.args[3], length) or length
 
return partialTable(frame, firstRow, lastRow)
 
end
 
end
   
Line 99: Line 103:
 
-- Like tableRange, but searches for two strings to determine the range.
 
-- Like tableRange, but searches for two strings to determine the range.
 
-- {{#invoke:table|tableRangeByString|(table)|1970|1980}} produces a table starting from the first row that contains 1970 to the first row that contains 1980.
 
-- {{#invoke:table|tableRangeByString|(table)|1970|1980}} produces a table starting from the first row that contains 1970 to the first row that contains 1980.
local wikitable = frame.args[1]
 
local rowP = rowPositions(wikitable)
 
local length = rows(wikitable)
 
 
local firstRow = findFirstRow(wikitable, frame.args[2]) or 1
 
local firstRow = findFirstRow(wikitable, frame.args[2]) or 1
 
local lastRow = findFirstRow(wikitable, frame.args[3]) - 1 or length - 1
 
local lastRow = findFirstRow(wikitable, frame.args[3]) - 1 or length - 1
  +
return partialTable(frame, firstRow, lastRow)
local header = string.sub(wikitable, 1, rowP[1] - 1)
 
local body = fetchRows(wikitable, firstRow, lastRow)
 
return header .. body .. "}"
 
 
end
 
end
   
Please note that all contributions to the Ace Attorney Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)

Template used on this page: