Module:Weapon Upgrades

--Module:Sandbox --Table local p = {}

--This function is for normal weapons, such as Taran and Hydra, which have no quirks. function p.normalUpgrade(frame) --Import Arguments stats = frame:getParent.args --Read in ammunition, cycle time, Reload time Level_base = formatnum(stats["base-level"]) rounds = formatnum(stats["rounds"]) time_cycle = formatnum(stats["cycle-time"]) time_reload = formatnum(stats["reload-time"]) mk2 = Logic(stats["mark-2"])

--Calculate unload time time_unload = time_cycle - time_reload --Generate Heading if not mk2 then tab = "==Upgrade Details==\n" else tab = "==Mark II Upgrade Details==\n" end --generate table header tab =tab .. "{| class=\"article-table weapon-upgrades\"\n! Level\n! Damage\n! Cost (Ag)\n!Time\n!Burst DPS\n!Cycle DPS\n!Cycle Damage\n" --Loop through all levels, skipping nonexistent ones for n=Level_base,12 do       tab = tab .. "|-\n! " ..n .."\n|\n|\n|\n|\n|\n|\n" end --End table tab = tab .. "|}"

--DEBUG OUTPUT, ONLY ENABLE IF THERE IS AN ERROR --return " "..tab.." " return tab end

--Function for rounding function round(x) return math.floor(x+.5) end

--Function for converting strings to numbers function formatnum(str) return tonumber(string.gsub(str,",",""),10) end

--Function for converting Logic-string inputs to logic values function Logic(val) if val == "true" then return true else return false end end

--Return table return p