Difference between revisions of "Module:Sandbox/Andy M. Wang/Sandbox/sandbox"
< Module:Sandbox | Andy M. Wang | Sandbox
Jump to navigation
Jump to search
blackwiki>Andy M. Wang m (syntax (self-trout much?)) |
blackwiki>Andy M. Wang (-0.0002 ?) |
||
| Line 18: | Line 18: | ||
} | } | ||
altitude = altitude or 0 | altitude = altitude or 0 | ||
| − | local sign = (altitude < 0) and -0. | + | local sign = (altitude < 0) and -0.0002 or 0.5 |
local scale = math.floor(altitude / 5000 + sign) | local scale = math.floor(altitude / 5000 + sign) | ||
scale = math.min(60, math.max(-3, scale)) | scale = math.min(60, math.max(-3, scale)) | ||
Revision as of 04:56, 24 April 2016
Documentation for this module may be created at Module:Sandbox/Andy M. Wang/Sandbox/sandbox/doc
-- For unit tests, see [[Module:Sandbox/Andy M. Wang/Sandbox/testcases]]
local p = {}
function p.hello()
return "Hello, world!"
end
function p.speed_of_sound(frame)
local altitude = tonumber(frame.args[1]) -- args[0] is speed_of_sound
local mach_table = { -- scale =
799.5, 787.0, 774.2, 761.207051, -- -3 to 0
748.0, 734.6, 721.0, 707.0, 692.8, 678.3, 663.5, 660.1, 660.1, 660.1, -- 1 to 10
660.1, 660.1, 660.1, 662.0, 664.3, 666.5, 668.9, 671.1, 673.4, 675.6, -- 11 to 20
677.9, 683.7, 689.9, 696.0, 702.1, 708.1, 714.0, 719.9, 725.8, 731.6, -- 21 to 30
737.3, 737.7, 737.7, 736.2, 730.5, 724.6, 718.8, 712.9, 707.0, 701.1, -- 31 to 40
695.0, 688.9, 682.8, 676.6, 670.4, 664.1, 657.8, 652.9, 648.3, 643.7, -- 41 to 50
639.1, 634.4, 629.6, 624.8, 620.0, 615.2, 613.2, 613.2, 613.2, 613.5, -- 51 to 60
}
altitude = altitude or 0
local sign = (altitude < 0) and -0.0002 or 0.5
local scale = math.floor(altitude / 5000 + sign)
scale = math.min(60, math.max(-3, scale))
return mach_table[scale + 4] * 0.44704 .. '|' .. scale .. '|' .. altitude -- mph converted to m/s
end
return p