Module:Size: Difference between revisions
From Teriock
More actions
// via Wikitext Extension for VSCode |
No edit summary |
||
| (16 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local function calcWeight ( size ) | |||
return math.floor((3 + size)^3 + 0.5) | |||
end | |||
local function calcCarryingCapacity ( size, str, mult ) | |||
return mult * (65 + (20 * (str + (math.max(0, size - 4) ^ 2)))) | |||
end | |||
function p.weight ( frame ) | function p.weight ( frame ) | ||
local args = frame.args | local args = frame.args | ||
local size = tonumber(args.size) or 1 | local size = tonumber(args.size) or 1 | ||
local weight = tostring(( | local weight = tostring(calcWeight(size)) .. ' lb.' | ||
return weight | return weight | ||
end | end | ||
| Line 12: | Line 20: | ||
local size = tonumber(args.size) or 1 | local size = tonumber(args.size) or 1 | ||
local str = tonumber(args.str) or 0 | local str = tonumber(args.str) or 0 | ||
local mult = tonumber(args.mult) or 1 | |||
if size < 5 then | if size < 5 then | ||
local carryingCapacity = tostring((60 + (20 * str))) .. ' lb.' | local carryingCapacity = tostring(mult * (60 + (20 * str))) .. ' lb.' | ||
else | else | ||
local carryingCapacity = tostring(( | local carryingCapacity = tostring((mult * (65 + (20 * (str + (size - 5))))) ^ 2) .. ' lb.' | ||
end | end | ||
return carryingCapacity | return carryingCapacity | ||
end | |||
function p.weightTable ( frame ) | |||
local args = frame.args | |||
local minSize = tonumber(args.minSize) or 1 | |||
local maxSize = tonumber(args.maxSize) or 10 | |||
local out = '' | |||
for i = minSize, maxSize do | |||
local minWeight = tostring(calcWeight(i - 0.5)) .. ' lb.' | |||
local midWeight = tostring(calcWeight(i)) .. ' lb.' | |||
local maxWeight = tostring(calcWeight(i + 0.5)) .. ' lb.' | |||
out = out .. '|-\n|' .. i .. '||' .. minWeight .. '||' .. midWeight .. '||' .. maxWeight .. '\n' | |||
end | |||
return out | |||
end | |||
function p.carryingCapacityTable ( frame ) | |||
local args = frame.args | |||
local minSize = tonumber(args.minSize) or 1 | |||
local maxSize = tonumber(args.maxSize) or 10 | |||
local minStr = tonumber(args.minStr) or -3 | |||
local maxStr = tonumber(args.maxStr) or 5 | |||
local mult = tonumber(args.mult) or 1 | |||
local out = '' | |||
for i = minSize, maxSize do | |||
out = out .. '|-\n|' .. i | |||
for j = minStr, maxStr do | |||
local carryingCapacity = tostring(calcCarryingCapacity(i, j, mult)) .. ' lb.' | |||
out = out .. '||' .. carryingCapacity | |||
end | |||
out = out .. '\n' | |||
end | |||
return out | |||
end | end | ||
return p | return p | ||
Latest revision as of 17:50, 27 April 2026
Documentation for this module may be created at Module:Size/doc
local p = {}
local function calcWeight ( size )
return math.floor((3 + size)^3 + 0.5)
end
local function calcCarryingCapacity ( size, str, mult )
return mult * (65 + (20 * (str + (math.max(0, size - 4) ^ 2))))
end
function p.weight ( frame )
local args = frame.args
local size = tonumber(args.size) or 1
local weight = tostring(calcWeight(size)) .. ' lb.'
return weight
end
function p.carryingCapacity ( frame )
local args = frame.args
local size = tonumber(args.size) or 1
local str = tonumber(args.str) or 0
local mult = tonumber(args.mult) or 1
if size < 5 then
local carryingCapacity = tostring(mult * (60 + (20 * str))) .. ' lb.'
else
local carryingCapacity = tostring((mult * (65 + (20 * (str + (size - 5))))) ^ 2) .. ' lb.'
end
return carryingCapacity
end
function p.weightTable ( frame )
local args = frame.args
local minSize = tonumber(args.minSize) or 1
local maxSize = tonumber(args.maxSize) or 10
local out = ''
for i = minSize, maxSize do
local minWeight = tostring(calcWeight(i - 0.5)) .. ' lb.'
local midWeight = tostring(calcWeight(i)) .. ' lb.'
local maxWeight = tostring(calcWeight(i + 0.5)) .. ' lb.'
out = out .. '|-\n|' .. i .. '||' .. minWeight .. '||' .. midWeight .. '||' .. maxWeight .. '\n'
end
return out
end
function p.carryingCapacityTable ( frame )
local args = frame.args
local minSize = tonumber(args.minSize) or 1
local maxSize = tonumber(args.maxSize) or 10
local minStr = tonumber(args.minStr) or -3
local maxStr = tonumber(args.maxStr) or 5
local mult = tonumber(args.mult) or 1
local out = ''
for i = minSize, maxSize do
out = out .. '|-\n|' .. i
for j = minStr, maxStr do
local carryingCapacity = tostring(calcCarryingCapacity(i, j, mult)) .. ' lb.'
out = out .. '||' .. carryingCapacity
end
out = out .. '\n'
end
return out
end
return p