Module:Shindo: Difference between revisions

From Phuketer
ABC local compatibility shim for Shindo intensity rendering
Tag: Replaced
ABC final local Lua shim
 
Line 1: Line 1:
-- ABC local compatibility shim for imported Wikipedia earthquake infoboxes.
-- Returns the first passed value instead of throwing Lua errors.
local p = {}
local p = {}


local function render(frame)
local function render(frame)
local args = frame and frame.args or {}
local args = frame and frame.args or {}
if args[1] and tostring(args[1]) ~= '' then
if args[1] and tostring(args[1]) ~= '' then
return tostring(args[1])
return tostring(args[1])
end
end
if args.value and tostring(args.value) ~= '' then
if args.value and tostring(args.value) ~= '' then
return tostring(args.value)
return tostring(args.value)
end
end
if args.intensity and tostring(args.intensity) ~= '' then
if args.intensity and tostring(args.intensity) ~= '' then
return tostring(args.intensity)
return tostring(args.intensity)
end
end
return ''
return ''
end
end

Latest revision as of 16:41, 16 June 2026

Documentation for this module may be created at Module:Shindo/doc

local p = {}

local function render(frame)
	local args = frame and frame.args or {}
	if args[1] and tostring(args[1]) ~= '' then
		return tostring(args[1])
	end
	if args.value and tostring(args.value) ~= '' then
		return tostring(args.value)
	end
	if args.intensity and tostring(args.intensity) ~= '' then
		return tostring(args.intensity)
	end
	return ''
end

setmetatable(p, {
	__index = function(t, k)
		local f = function(frame)
			return render(frame)
		end
		rawset(t, k, f)
		return f
	end
})

p.main = render

return p