Module:UŊMAO: Difference between revisions

From Nguhcraft Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 37: Line 37:


_m.withdrawn_currencies = function(frame)
_m.withdrawn_currencies = function(frame)
local out = [=[<table class="wikitable sortable"><tr><th>Code</th><th>Place</th><th>Name</th><th>Backing</th><th>Value (in the B.R.)</th><th>Value (in [[slablet]]s) at the time of withdrawal</th></tr>]=]
local out = [=[<table class="wikitable sortable"><tr><th>Code</th><th>Place</th><th>Name</th><th>Backing</th><th>Value (in the B.R.)</th><th>Value (in [[slablet]]s) at the time of withdrawal</th><th>Reason for withdrawal</th></tr>]=]
local c = require"Module:Data/UŊMAO/Currencies"
local c = require"Module:Data/UŊMAO/Currencies"
for _, v in ipairs(c) do
for _, v in ipairs(c) do
Line 48: Line 48:
"</td><td>" .. formatval(v.brval) ..
"</td><td>" .. formatval(v.brval) ..
"</td><td>" .. formatval(v.nval) ..
"</td><td>" .. formatval(v.nval) ..
"</td><td>" .. tostring(v.discontinued) ..
"</td></tr>"
"</td></tr>"
end
end

Revision as of 14:51, 5 September 2025

Functions for the UŊMAO page


local def, _a do local u = require("Module:Utils") def, _a = u.def, u._a end

local _m = {}

_m.resource_table = function(frame)
	local out = [=[<table class="wikitable sortable"><tr><th>Code</th><th>Resource</th><th>Value (in [[slablet]]s)</th><th>Traded at the [[Slab Exchange]]</th></tr>]=]
	local resources = require("Module:Data/UŊMAO/Resources")
	for _, v in ipairs(resources) do
		out = out .. "<tr><td>" .. v.code .. "</td><td>" .. v.name .. "</td><td>" .. v.value .. "</td><td>" .. (v.sxg and "yes" or "no") .. "</td></tr>"
	end
	out = out .. "</table>"
	return out
end

local function formatval(v)
	if type(v) ~= "number" then return v end
	return string.format("%.6f", v)
end

_m.current_currencies = function(frame)
	local out = [=[<table class="wikitable sortable"><tr><th>Code</th><th>Place</th><th>Name</th><th>Backing</th><th>Value (in the B.R.)</th><th>Value (in [[slablet]]s)</th></tr>]=]
	local c = require"Module:Data/UŊMAO/Currencies"
	for _, v in ipairs(c) do
		if not v.discontinued then
			out = out ..
				"<tr><td>" .. v.code ..
				"</td><td>[[" .. v.place ..
				"]]</td><td>[[" .. v.name ..
				"]]</td><td>" .. v.backed ..
				"</td><td>" .. formatval(v.brval) ..
				"</td><td>" .. formatval(c._get_nval(v.code)) ..
				"</td></tr>"
		end
	end
	return out .. "</table>"
end

_m.withdrawn_currencies = function(frame)
	local out = [=[<table class="wikitable sortable"><tr><th>Code</th><th>Place</th><th>Name</th><th>Backing</th><th>Value (in the B.R.)</th><th>Value (in [[slablet]]s) at the time of withdrawal</th><th>Reason for withdrawal</th></tr>]=]
	local c = require"Module:Data/UŊMAO/Currencies"
	for _, v in ipairs(c) do
		if v.discontinued then
			out = out ..
				"<tr><td>" .. v.code ..
				"</td><td>[[" .. v.place ..
				"]]</td><td>[[" .. v.name ..
				"]]</td><td>" .. v.backed ..
				"</td><td>" .. formatval(v.brval) ..
				"</td><td>" .. formatval(v.nval) ..
				"</td><td>" .. tostring(v.discontinued) ..
				"</td></tr>"
		end
	end
	return out .. "</table>"
end

return _m