432
edits
No edit summary |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 291: | Line 291: | ||
function p.hex(frame) | function p.hex(frame) | ||
-- Default behavior, when no coords supplied | -- Default behavior, when no coords supplied | ||
if frame.args == nil then | if (frame == nil or frame.args['x'] == nil or frame.args['y'] == nil) then | ||
return 'Hex' | return 'Hex' | ||
end | end | ||
local X = tonumber(frame.args['x']) | local X = tonumber(frame.args['x']) | ||
local Y = tonumber(frame.args['y']) | local Y = tonumber(frame.args['y']) | ||
if X == nil or Y == nil then | |||
return '<invalid XY format>' | |||
end | |||
local hex = p.getPointOfInterestByXY(X, Y) | local hex = p.getPointOfInterestByXY(X, Y) | ||
-- nil means coord is invalid | -- nil means coord is invalid | ||
Line 304: | Line 307: | ||
local noicon = frame.args['noicon'] or false | local noicon = frame.args['noicon'] or false | ||
local nolink = frame.args['nolink'] or false | local nolink = frame.args['nolink'] or false | ||
local coords = '<span>(' .. X .. ', ' .. Y .. ')</span>' | local coords = '<span>(' .. X .. ',' .. Y .. ')</span>' | ||
-- Valid, but not a POI | -- Valid, but not a POI | ||
if hex['id'] == nil or noicon then | if hex['id'] == nil or noicon then | ||
Line 310: | Line 313: | ||
end | end | ||
-- Valid POI | -- Valid POI | ||
local poi_icon = Icons.Icon({hex['name'], type='poi', notext=notext, nolink=nolink, size='25'}) | local poi_icon = Icons.Icon({hex['name'], type='poi', notext=notext or nil, nolink=nolink or nil, size='25'}) | ||
return '<span>' .. poi_icon .. coords .. '</span>' | return '<span>' .. poi_icon .. ' ' .. coords .. '</span>' | ||
end | end | ||
edits