Module:Sandbox/Skills/Cartography: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 29: Line 29:
end
end
end
end
return nil
return hex
end
end


Line 265: Line 265:
local itemNames = frame.args ~= nil and frame.args[1] or frame
local itemNames = frame.args ~= nil and frame.args[1] or frame
local items = {}
local items = {}
for itemName in string.gmatch(itemNames, "([^,]+),%s*") do
for itemName in string.gmatch(itemNames, "[^,]*") do
item = Items.getItem(itemName)
item = Items.getItem(itemName)
if item ~= nil then
if item ~= nil then
items.insert(item)
table.insert(items, item)
end
end
end
end
Line 287: Line 287:
end
end
return table.concat(testTable)
return table.concat(testTable)
end
function p.hex(frame)
-- Default behavior, when no coords supplied
if (frame == nil or frame.args['x'] == nil or frame.args['y'] == nil) then
return 'Hex'
end
local X = tonumber(frame.args['x'])
local Y = tonumber(frame.args['y'])
if X == nil or Y == nil then
return '<invalid XY format>'
end
local hex = p.getPointOfInterestByXY(X, Y)
-- nil means coord is invalid
if hex == nil then
return '<invalid XY coord>'
end
local notext = frame.args['notext'] or false
local noicon = frame.args['noicon'] or false
local nolink = frame.args['nolink'] or false
local coords = '<span>(' .. X .. ',' .. Y .. ')</span>'
-- Valid, but not a POI
if hex['id'] == nil or noicon then
return coords
end
-- Valid POI
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>'
end
end


432

edits