Module:TAMNAMS: Difference between revisions

Ganaram inukshuk (talk | contribs)
Added tables for step ratios
Ganaram inukshuk (talk | contribs)
No edit summary
Line 1: Line 1:
-- Module for TAMNAMS-related things as it pertains to mosses
-- Module for TAMNAMS-related things as it pertains to mosses
-- This module is meant to be used with other modules, not as part of a template
-- Work in progress
-- Work in progress
local mos = require('Module:MOS')
local mos = require('Module:MOS')
local rat = require('Module:Rational')
local p = {}
local p = {}


Line 209: Line 211:
end
end


function p.lookup_named_ancestor(input_mos)
-- Function for looking up a step ratio range
-- Module:Rational is used to help simplify ratios
function p.lookup_step_ratio(step_ratio, use_extended)
local step_ratio = step_ratio or rat.new(2, 1)
local use_extended = use_extended == true
-- Produce the key needed to lookup the step ratio name
-- use_extended is used to toggle between central range and extended range
local key = rat.as_ratio(step_ratio, ':')
if use_extended then
return p.tamnams_ratios_ext[key]
else
return p.tamnams_ratios[key]
end
end
 
-- Function for looking up a step ratio range
-- Module:Rational is used to help simplify ratios
function p.lookup_step_ratio_range(step_ratio_1, step_ratio_2, use_extended)
local step_ratio_1 = step_ratio_1 or rat.new(1, 0)
local step_ratio_2 = step_ratio_2 or rat.new(2, 1)
local use_extended = use_extended == true
-- Produce the key needed for the lookup table as a/b to c/d
-- Swap ratios if ratio 1 has a higher hardness than ratio 2
local key = ""
local float_1 = rat.as_float(step_ratio_1)
local float_2 = rat.as_float(step_ratio_2)
if (float_1 > float_2) then
key = string.format('%s to %s', rat.as_ratio(step_ratio_2, ':'), rat.as_ratio(step_ratio_1, ':'))
else
key = string.format('%s to %s', rat.as_ratio(step_ratio_1, ':'), rat.as_ratio(step_ratio_2, ':'))
end
-- use_extended is used to toggle between central range and extended range
if use_extended then
return p.tamnams_ranges_ext[key]
else
return p.tamnams_ranges[key]
end
end
end


function p.lookup_step_ratio(step_ratio)
function p.lookup_named_ancestor(input_mos)
end
end


function p.lookup_step_ratio_range(step_ratio)
function p.tester()
return p.lookup_step_ratio_range(rat.new(10, 1), rat.new(1, 0), true)
end
end


return p
return p